5A关系资产(用户趋势)

云图扩展工具

  1. // ==UserScript==
  2. // @name 5A关系资产(用户趋势)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_brand/assets/crowd/distribution?*
  8. // @grant none
  9. // @icon https://lf3-static.bytednsdoc.com/obj/eden-cn/prhaeh7pxvhn/yuntu/yuntu-logo_default.svg
  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://gf.qytechs.cn/scripts/404478-jsonexportexcel-min/code/JsonExportExcelmin.js?version=811266
  13. // @require https://gf.qytechs.cn/scripts/463728-lodash-js/code/lodashjs.js?version=1174104
  14. // @require https://gf.qytechs.cn/scripts/455576-qmsg/code/Qmsg.js?version=1122361
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. "use strict";
  19.  
  20. var new_element = document.createElement("link");
  21. new_element.setAttribute("rel", "stylesheet");
  22. new_element.setAttribute("href", "https://qmsg.refrain.xyz/message.min.css");
  23. document.body.appendChild(new_element);
  24.  
  25. const button = document.createElement("div");
  26. button.textContent = "用户趋势";
  27. Object.assign(button.style, {
  28. height: "34px",
  29. lineHeight: "var(--line-height, 34px)",
  30. alignItems: "center",
  31. color: "white",
  32. background: "linear-gradient(60deg, rgb(95, 240, 225), rgb(47, 132, 254))",
  33. marginLeft: "10px",
  34. fontSize: "13px",
  35. padding: "0 10px",
  36. cursor: "pointer",
  37. fontWeight: "500",
  38. });
  39. button.addEventListener("click", urlClick); //监听按钮点击事件
  40.  
  41. //message.js
  42. let loadingMsg = null;
  43.  
  44. //目标数据
  45. let target_data = null;
  46.  
  47. (function listen() {
  48. var origin = {
  49. open: XMLHttpRequest.prototype.open,
  50. send: XMLHttpRequest.prototype.send,
  51. };
  52. XMLHttpRequest.prototype.open = function (a, b) {
  53. this.addEventListener("load", replaceFn);
  54. origin.open.apply(this, arguments);
  55. };
  56. XMLHttpRequest.prototype.send = function (a, b) {
  57. origin.send.apply(this, arguments);
  58. };
  59. function replaceFn(obj) {
  60. if (
  61. this?._url?.slice(0, 41) ==
  62. "/yuntu_ng/api/v1/get_audience_asset_trend"
  63. ) {
  64. target_data = JSON.parse(obj?.target?.response);
  65. }
  66. }
  67. })();
  68.  
  69.  
  70. function appendDoc() {
  71. setTimeout(() => {
  72. var like_comment = document.querySelector(
  73. ".header-BBQ8Fc"
  74. );
  75. if (like_comment) {
  76. like_comment.append(button); //把按钮加入到 x 的子节点中
  77. return;
  78. }
  79. appendDoc();
  80. }, 1000);
  81. }
  82. appendDoc();
  83.  
  84. function expExcel(e) {
  85. let data = e?.data?.trend_points
  86. let contrast = {
  87. "日期":"date",
  88. "本品牌总资产":"cover_num",
  89. "本品牌日新增":"day_added",
  90. "本品牌日流失":"day_loss",
  91. "对比品牌总资产":"count_average",
  92. "对比品牌日新增":"day_added_compare",
  93. "对比品牌日流失":"day_loss_compare",
  94. }
  95.  
  96. let option = {};
  97. option.fileName = "5A关系资产(用户趋势)"; //文件名
  98. option.datas = [{
  99. sheetName: '',
  100. sheetData: data,
  101. sheetHeader: Object.keys(contrast),
  102. sheetFilter: Object.values(contrast),
  103. columnWidths: [], // 列宽
  104. }]
  105. var toExcel = new ExportJsonExcel(option);
  106. toExcel.saveExcel();
  107. loadingMsg.close();
  108. }
  109.  
  110. async function urlClick() {
  111. if (target_data) {
  112. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  113. expExcel(target_data)
  114. }else{
  115. loadingMsg = Qmsg.error("数据加载失败,请刷新页面");
  116. }
  117. }
  118.  
  119. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址