商品_行业洞察_市场构成

云图扩展工具

目前為 2023-07-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 商品_行业洞察_市场构成
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_ng/product/industry/marketAweme?*
  8. // @icon https://www.google.com/s2/favicons?domain=oceanengine.com
  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. const button = document.createElement("div");
  25. button.textContent = "导出数据";
  26. Object.assign(button.style, {
  27. height: "34px",
  28. lineHeight: "var(--line-height, 34px)",
  29. alignItems: "center",
  30. color: "#FFF",
  31. background: "linear-gradient(60deg, rgb(95, 240, 225), rgb(47, 132, 254))",
  32. borderRadius: "5px",
  33. margin: "0 10px",
  34. fontSize: "13px",
  35. padding: "0 10px",
  36. cursor: "pointer",
  37. fontWeight: "500",
  38. });
  39. button.addEventListener("click", urlClick);
  40.  
  41. let fetchList = [];
  42.  
  43. window.au_fetch = window.fetch;
  44. window.fetch = async (...args) => {
  45. let [resource, config] = args;
  46. // request interceptor here
  47. const response = await window.au_fetch(resource, config);
  48. if (
  49. response.url.slice(0, 87) ==
  50. "https://yuntu.oceanengine.com/product_node/api/graphql/?op=getIndustryInsightAwemeStats"
  51. ) {
  52. fetchList.push({ response, body: args[1].body });
  53. }
  54. return response;
  55. };
  56.  
  57. //message.js
  58. let loadingMsg = null;
  59.  
  60. function appendDoc() {
  61. const likeComment = document.querySelector(
  62. ".right"
  63. );
  64. if (likeComment) {
  65. likeComment.append(button);
  66. return;
  67. }
  68. setTimeout(appendDoc, 1000);
  69. }
  70. appendDoc();
  71.  
  72. async function getData() {
  73. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  74.  
  75. let body = fetchList[fetchList.length - 1].body;
  76. var xhr = new XMLHttpRequest();
  77. xhr.withCredentials = true;
  78.  
  79. xhr.addEventListener("readystatechange", function () {
  80. if (this.readyState === 4) {
  81. let _this = JSON.parse(this.responseText);
  82. let expData = _this?.data?.industryInsightAwemeStats?.list?.map((v) => {
  83. return {
  84. ...v.aweme,
  85. perUidOrderCnt: v.data.perUidOrderCnt.value,
  86. perUidPurchaseProductCnt: v.data.perUidPurchaseProductCnt.value,
  87. productAvgPrice: v.data.productAvgPrice.value,
  88. productCnt: v.data.productCnt.value,
  89. purchaseUidCnt: v.data.purchaseUidCnt.value,
  90. salesAmount: v.data.salesAmount.value,
  91. salesAmountRank: v.data.salesAmount.rank,
  92. salesVolune: v.data.salesVolune.value,
  93. };
  94. });
  95. expExcel(expData);
  96. }
  97. });
  98. xhr.open("POST", fetchList[fetchList.length - 1].response.url);
  99. xhr.setRequestHeader("authority", "yuntu.oceanengine.com");
  100. xhr.setRequestHeader("accept", "*/*");
  101. xhr.setRequestHeader("accept-language", "zh-CN,zh;q=0.9");
  102. xhr.setRequestHeader("content-type", "application/json");
  103.  
  104. xhr.send(body);
  105. return;
  106. }
  107.  
  108. function expExcel(e) {
  109. let contrast = {
  110. '排名': "salesAmountRank",
  111. '头像': "imageUrl",
  112. '名称': "name",
  113. '抖音号': "awemeId",
  114. '抖音号类型': "authorType",
  115. '主推类目': "liveMainCategory",
  116. "销售金额(指数)": "salesAmount",
  117. "销售量(指数)": "salesVolune",
  118. "购买人数(指数)": "purchaseUidCnt",
  119. "商品数(指数)": "productCnt",
  120. "人均购买频次(指数)": "perUidOrderCnt",
  121. "人均购买量(指数)": "perUidPurchaseProductCnt",
  122. };
  123. let fileName = "抖音号分析";
  124. let option = {};
  125. option.fileName = fileName; //文件名
  126. option.datas = [
  127. {
  128. sheetName: "",
  129. sheetData: e,
  130. sheetHeader: Object.keys(contrast),
  131. sheetFilter: Object.values(contrast),
  132. columnWidths: [], // 列宽
  133. },
  134. ];
  135. var toExcel = new ExportJsonExcel(option);
  136. toExcel.saveExcel();
  137. setTimeout(() => {
  138. loadingMsg.close();
  139. }, 1000);
  140. }
  141.  
  142. function urlClick() {
  143. getData();
  144. }
  145. })();

QingJ © 2025

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