Greasy Fork is available in English.

商品概览_货品结构分析

云图扩展工具

  1. // ==UserScript==
  2. // @name 商品概览_货品结构分析
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_brand/product/productOverview/productStructure?*
  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://greasyfork.org/scripts/404478-jsonexportexcel-min/code/JsonExportExcelmin.js?version=811266
  13. // @require https://greasyfork.org/scripts/455576-qmsg/code/Qmsg.js?version=1122361
  14. // ==/UserScript==
  15.  
  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.  
  23. const button = document.createElement("div");
  24. button.textContent = "导出数据";
  25. Object.assign(button.style, {
  26. height: "34px",
  27. lineHeight: "var(--line-height, 34px)",
  28. alignItems: "center",
  29. color: "white",
  30. background: "linear-gradient(90deg, rgba(0, 239, 253), rgba(64, 166, 254))",
  31. borderRadius: "5px",
  32. marginLeft: "10px",
  33. fontSize: "13px",
  34. padding: "0 10px",
  35. cursor: "pointer",
  36. fontWeight: "500",
  37. });
  38. button.addEventListener("click", urlClick);
  39.  
  40. function appendDoc() {
  41. const likeComment = document.querySelector(".ProductAnalysis__Selector-xYEIw.dizBso");
  42. if (likeComment) {
  43. likeComment.append(button);
  44. return;
  45. }
  46. setTimeout(appendDoc, 1000);
  47. }
  48. appendDoc();
  49.  
  50. //message.js
  51. let loadingMsg = null;
  52.  
  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 (
  70. this?._url?.slice(0, 49) ==
  71. "/product_node/v2/api/productOverview/itemAnalysis"
  72. ) {
  73. target_data = JSON.parse(obj?.target?.response);
  74. }
  75. }
  76. })();
  77.  
  78. async function getData(e) {
  79. expExcel(e)
  80. }
  81.  
  82.  
  83. function expExcel(e) {
  84.  
  85. let fileName = `货品结构分析`
  86.  
  87. let data = e.data?.list.map(v=>{
  88. return {...v,category:`${v.firstCategoryName}-${v.secondCategoryName}-${v.thirdCategoryName}`}
  89. })
  90. let contrast = {
  91. 排名: "rank",
  92. 商品信息: "itemName",
  93. 商品ID:"itemId",
  94. 图片链接:"imgUrl",
  95. 商品品类: "category",
  96. 销售额:"value",
  97. 销售额占比:"ratio",
  98. 销售量:"salesVolumn",
  99. 曝光人数:"showUidCnt",
  100. 点击人数:"clickUidCnt",
  101. 购买人数:"purchaseUidCnt",
  102. 点击率:"showClickRatio",
  103. 转化率:"clickPurchaseRatio",
  104. 曝光_购买转化率:"showPurchaseRatio",
  105. GPM:"gpm",
  106. 客单价:"perUidValue",
  107. A4拉新人数:"pullA4Cnt",
  108. 拉新率:"pullA4Ratio",
  109. 爆品指数:"productScore",
  110. };
  111.  
  112. let option = {};
  113. option.fileName = fileName; //文件名
  114. option.datas = [
  115. {
  116. sheetName: "",
  117. sheetData: data,
  118. sheetHeader: Object.keys(contrast),
  119. sheetFilter: Object.values(contrast),
  120. columnWidths: [], // 列宽
  121. }
  122. ];
  123. var toExcel = new ExportJsonExcel(option);
  124. toExcel.saveExcel();
  125. loadingMsg.close();
  126. }
  127.  
  128. function urlClick() {
  129. if (target_data) {
  130. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  131. getData(target_data);
  132. } else {
  133. loadingMsg = Qmsg.error("数据加载失败,请刷新页面!");
  134. }
  135. }
  136. })();