商品_价位段Top商品

云图扩展工具

目前为 2024-04-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 商品_价位段Top商品
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_brand/product/segmentedMarketDetail/marketProduct?*
  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. 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. position: "absolute",
  39. top: "10px",
  40. right: "10px",
  41. zIndex: "999"
  42. });
  43. button.addEventListener("click", urlClick);
  44.  
  45. const getRequestOptions = {
  46. method: "GET",
  47. redirect: "follow",
  48. };
  49.  
  50.  
  51. //message.js
  52. let loadingMsg = null;
  53.  
  54. let target_data = null;
  55.  
  56. (function listen() {
  57. var origin = {
  58. open: XMLHttpRequest.prototype.open,
  59. send: XMLHttpRequest.prototype.send,
  60. };
  61. XMLHttpRequest.prototype.open = function (a, b) {
  62. this.addEventListener("load", replaceFn);
  63. origin.open.apply(this, arguments);
  64. };
  65. XMLHttpRequest.prototype.send = function (a, b) {
  66. origin.send.apply(this, arguments);
  67. };
  68. function replaceFn(obj) {
  69. if (this?._url?.slice(0, 49) == "/product_node/v2/api/industry/insightProductStats") {
  70. target_data = JSON.parse(obj?.target?.response);
  71. }
  72. }
  73. })();
  74.  
  75. function appendDoc() {
  76. setTimeout(() => {
  77. var like_comment = document.querySelectorAll("body")[0];
  78. if (like_comment) {
  79. like_comment.append(button); //把按钮加入到 x 的子节点中
  80. return;
  81. }
  82. appendDoc();
  83. }, 1000);
  84. }
  85. appendDoc();
  86.  
  87. function checkElement() {
  88. const targetElement = document.querySelector(".DrawerCloseBtn__CloseBtn-ciPfX.CLSfX");
  89. if (targetElement) {
  90. button.style.display = "block";
  91. } else {
  92. button.style.display = "none";
  93. }
  94. }
  95.  
  96. const intervalId = setInterval(checkElement, 1000);
  97.  
  98. function getData(e){
  99. let data = e.data.list.map(v=>{
  100. return {
  101. '商品名称':v.product.name,
  102. 'ID':v.product.id,
  103. '销售金额':v.data.salesAmount.value,
  104. '销售量':v.data.salesVolune.value,
  105. '购买人数':v.data.purchaseUidCnt.value,
  106. }
  107. })
  108.  
  109. expExcel(data)
  110. }
  111.  
  112. function expExcel(data) {
  113. let title = document.querySelector(".DrillingChartDrawerContainer__SubTitle-kuqyDX.bvhnkz").innerHTML;
  114. let contrast = {
  115. '商品名称': '商品名称',
  116. 'ID': 'ID',
  117. '销售金额': '销售金额',
  118. '销售量': '销售量',
  119. '购买人数': '购买人数'
  120. };
  121.  
  122. let fileName = title;
  123.  
  124. setTimeout(() => {
  125. let option = {};
  126. option.fileName = fileName; //文件名
  127. option.datas =[{
  128. sheetName: "",
  129. sheetData: data,
  130. sheetHeader: Object.keys(contrast),
  131. sheetFilter: Object.values(contrast),
  132. columnWidths: [], // 列宽
  133. }];
  134. var toExcel = new ExportJsonExcel(option);
  135. toExcel.saveExcel();
  136. setTimeout(() => {
  137. loadingMsg.close();
  138. }, 1000);
  139. }, 1000);
  140. }
  141.  
  142. function urlClick() {
  143. if (target_data) {
  144. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  145. getData(target_data);
  146. } else {
  147. loadingMsg = Qmsg.error("数据加载失败,请重试");
  148. }
  149. }
  150. })();

QingJ © 2025

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