🏠 Home 

人群_机会人群_排名变化趋势

云图扩展工具

  1. // ==UserScript==
  2. // @name 人群_机会人群_排名变化趋势
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_brand/assets/industry_insight/industry?*
  8. // @icon https://lf3-static.bytednsdoc.com/obj/eden-cn/prhaeh7pxvhn/yuntu/yuntu-logo_default.svg
  9. // @grant none
  10. // @license MIT
  11. // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.2.1/jquery.min.js
  12. // @require https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js
  13. // @require https://greasyfork.org/scripts/404478-jsonexportexcel-min/code/JsonExportExcelmin.js?version=811266
  14. // @require https://greasyfork.org/scripts/455576-qmsg/code/Qmsg.js?version=1122361
  15. // ==/UserScript==
  16. (function () {
  17. "use strict";
  18. var new_element = document.createElement("link");
  19. new_element.setAttribute("rel", "stylesheet");
  20. new_element.setAttribute("href", "https://qmsg.refrain.xyz/message.min.css");
  21. document.body.appendChild(new_element);
  22. const button = document.createElement("div");
  23. button.textContent = "导出数据";
  24. Object.assign(button.style, {
  25. height: "34px",
  26. lineHeight: "var(--line-height, 34px)",
  27. alignItems: "center",
  28. color: "white",
  29. background: "linear-gradient(90deg, rgba(0, 239, 253), rgba(64, 166, 254))",
  30. borderRadius: "5px",
  31. marginLeft: "10px",
  32. fontSize: "13px",
  33. padding: "0 10px",
  34. cursor: "pointer",
  35. fontWeight: "500",
  36. });
  37. button.addEventListener("click", urlClick);
  38. //message.js
  39. let loadingMsg = null;
  40. //目标数据
  41. let target_data = null;
  42. (function listen() {
  43. var origin = {
  44. open: XMLHttpRequest.prototype.open,
  45. send: XMLHttpRequest.prototype.send,
  46. };
  47. XMLHttpRequest.prototype.open = function (a, b) {
  48. this.addEventListener("load", replaceFn);
  49. origin.open.apply(this, arguments);
  50. };
  51. XMLHttpRequest.prototype.send = function (a, b) {
  52. origin.send.apply(this, arguments);
  53. };
  54. function replaceFn(obj) {
  55. if (
  56. this?._url?.slice(0, 42) ==
  57. "/yuntu_ng/api/v1/IndustryPermeabilityTrend"
  58. ) {
  59. target_data = JSON.parse(obj?.target?.response);
  60. }
  61. }
  62. })();
  63. function appendDoc() {
  64. const likeComment = document.querySelectorAll(".assets-radio-group.assets-radio-group-type-filled.assets-radio-group-size-md")[1];
  65. if (likeComment) {
  66. likeComment.append(button);
  67. return;
  68. }
  69. setTimeout(appendDoc, 1000);
  70. }
  71. appendDoc();
  72. function expExcel(e) {
  73. let contrast = {
  74. "date": "日期",
  75. "rank": "本品排名",
  76. "compete_rank": "对牌品牌排名",
  77. }
  78. let option = {};
  79. option.fileName = "人群_机会人群_排名变化趋势"; //文件名
  80. option.datas = [{
  81. sheetName: '',
  82. sheetData: e.data.trend,
  83. sheetHeader: Object.values(contrast),
  84. sheetFilter: Object.keys(contrast),
  85. columnWidths: [], // 列宽
  86. }]
  87. var toExcel = new ExportJsonExcel(option);
  88. toExcel.saveExcel();
  89. loadingMsg.close();
  90. }
  91. function urlClick() {
  92. if (target_data) {
  93. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  94. expExcel(target_data);
  95. } else {
  96. loadingMsg = Qmsg.error("数据加载失败,请重试");
  97. }
  98. }
  99. })();