投后结案_流量分析_触点流量总览

云图扩展工具

  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/evaluation_brand/report/flow?*
  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://gf.qytechs.cn/scripts/404478-jsonexportexcel-min/code/JsonExportExcelmin.js?version=811266
  14. // @require https://gf.qytechs.cn/scripts/455576-qmsg/code/Qmsg.js?version=1122361
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. "use strict";
  19. var new_element = document.createElement("link");
  20. new_element.setAttribute("rel", "stylesheet");
  21. new_element.setAttribute("href", "https://qmsg.refrain.xyz/message.min.css");
  22. document.body.appendChild(new_element);
  23.  
  24. //指定SPU的人群资产重叠分布
  25.  
  26. const button = document.createElement("div");
  27. button.textContent = "导出数据";
  28. Object.assign(button.style, {
  29. height: "34px",
  30. lineHeight: "var(--line-height, 34px)",
  31. alignItems: "center",
  32. color: "white",
  33. background: "linear-gradient(90deg, rgba(0, 239, 253), rgba(64, 166, 254))",
  34. borderRadius: "5px",
  35. marginLeft: "10px",
  36. fontSize: "13px",
  37. padding: "0 10px",
  38. cursor: "pointer",
  39. fontWeight: "500",
  40. });
  41. button.addEventListener("click", urlClick);
  42.  
  43. //message.js
  44. let loadingMsg = null;
  45.  
  46. //目标数据
  47. let target_data = null;
  48.  
  49. (function listen() {
  50. var origin = {
  51. open: XMLHttpRequest.prototype.open,
  52. send: XMLHttpRequest.prototype.send,
  53. };
  54. XMLHttpRequest.prototype.open = function (a, b) {
  55. this.addEventListener("load", replaceFn);
  56. origin.open.apply(this, arguments);
  57. };
  58. XMLHttpRequest.prototype.send = function (a, b) {
  59. origin.send.apply(this, arguments);
  60. };
  61. function replaceFn(obj) {
  62. if (
  63. this?._url?.slice(0, 58) ==
  64. "/measurement/api/eva/get_evaluation_flow_by_trigger_result"
  65. ) {
  66. target_data = JSON.parse(obj?.target?.response);
  67. }
  68. }
  69. })();
  70.  
  71. function appendDoc() {
  72. const likeComment = document.querySelector(".styles-module__overview-extra--Tc0lo");
  73. if (likeComment) {
  74. likeComment.append(button);
  75. return;
  76. }
  77. setTimeout(appendDoc, 1000);
  78. }
  79. appendDoc();
  80.  
  81. function generatePointName(input) {
  82. let point_name = '';
  83. // 处理第一级触发点
  84. if (input.level_1_trigger_point) {
  85. point_name += input.level_1_trigger_point.query_type_point_name_zh;
  86. }
  87. // 处理第二级触发点
  88. if (input.level_2_trigger_point) {
  89. point_name += '/' + input.level_2_trigger_point.query_type_point_name_zh;
  90. }
  91. // 处理第三级触发点
  92. if (input.level_3_trigger_point) {
  93. point_name += '/' + input.level_3_trigger_point.query_type_point_name_zh;
  94. }
  95. return { point_name };
  96. }
  97.  
  98.  
  99. function expExcel(e) {
  100. let res = e.data.flow_by_trigger.map(v=>{
  101. return {...v.matix,...generatePointName(v.trigger_point)}
  102. })
  103. console.log(res)
  104. let contrast = {
  105. "触点": "point_name",
  106. "本品曝光次数": "pv",
  107. "本品曝光人数": "uv",
  108. "本品消耗金额": "cost"
  109. }
  110. let option = {};
  111. option.fileName = "投后结案_流量分析_触点流量总览"; //文件名
  112. option.datas = [{
  113. sheetName: '',
  114. sheetData: res,
  115. sheetHeader: Object.keys(contrast),
  116. sheetFilter: Object.values(contrast),
  117. columnWidths: [], // 列宽
  118. }]
  119. var toExcel = new ExportJsonExcel(option);
  120. toExcel.saveExcel();
  121. loadingMsg.close();
  122. }
  123.  
  124. function urlClick() {
  125. if (target_data) {
  126. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  127. expExcel(target_data);
  128. } else {
  129. loadingMsg = Qmsg.error("数据加载失败,请重试");
  130. }
  131. }
  132. })();

QingJ © 2025

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