品牌形象洞察_偏爱度

云图扩展工具

  1. // ==UserScript==
  2. // @name 品牌形象洞察_偏爱度
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description 云图扩展工具
  6. // @author siji-Xian
  7. // @match *://yuntu.oceanengine.com/yuntu_brand/image/insight/brand?indicator=4*
  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: "white",
  31. background: "linear-gradient(90deg, rgba(0, 239, 253), rgba(64, 166, 254))",
  32. borderRadius: "5px",
  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. let target_data1 = null;
  47.  
  48. (function listen() {
  49. var origin = {
  50. open: XMLHttpRequest.prototype.open,
  51. send: XMLHttpRequest.prototype.send,
  52. };
  53. XMLHttpRequest.prototype.open = function (a, b) {
  54. this.addEventListener("load", replaceFn);
  55. origin.open.apply(this, arguments);
  56. };
  57. XMLHttpRequest.prototype.send = function (a, b) {
  58. origin.send.apply(this, arguments);
  59. };
  60. function replaceFn(obj) {
  61. if (
  62. this?._url?.slice(0, 48) ==
  63. "/measurement/api/v2/image/get_preference_insight"
  64. ) {
  65. target_data = JSON.parse(obj?.target?.response);
  66. }
  67. if (
  68. this?._url?.slice(0, 45) ==
  69. "/measurement/api/v2/image/get_preference_tags"
  70. ) {
  71. target_data1 = JSON.parse(obj?.target?.response);
  72. }
  73. }
  74. })();
  75.  
  76. function appendDoc() {
  77. const likeComment = document.querySelector(".brand-image-tab-bar-extra");
  78. if (likeComment) {
  79. likeComment.append(button);
  80. return;
  81. }
  82. setTimeout(appendDoc, 1000);
  83. }
  84. appendDoc();
  85.  
  86. function expExcel() {
  87. let res = target_data.data.preference_insight.competition_analysis.voice_distribution
  88. let resData = res.map((v) => {
  89. return {
  90. ...v,
  91. brandCnt:v.positive_coappear_voice_cnt / v.coappear_voice_cnt,
  92. brandMakeCon:v.other_positive_coappear_voice_cnt / v.coappear_voice_cnt
  93. }
  94. }
  95. )
  96.  
  97. let data = [
  98. {
  99. sheetName:"竞争局势分析",
  100. sheetData:resData,
  101. contrast :{
  102. "brand_name": "品牌名称",
  103. "coappear_voice_cnt": "共现量级",
  104. "cover_cnt": "共现覆盖人数",
  105. "brandCnt": "本品牌偏爱占比",
  106. "brandMakeCon": "共现品牌偏爱占比",
  107. }
  108. },
  109. {
  110. sheetName:"品牌形象分析",
  111. sheetData:target_data1.data.tags,
  112. contrast :{
  113. "tag_name": "标签名称",
  114. "total_coappear_voice_cnt": "共现量级",
  115. "positive_coappear_voice_cnt": "本品牌偏爱量级",
  116. "coappear_brand_positive_voice_cnt": "共现品牌偏爱量级",
  117. "self_preference_rate": "本品牌偏爱占比",
  118. "coappear_brand_preference_rate": "共现品牌偏爱占比",
  119. "coappear_brand_top3": "主要共现品牌"
  120. }
  121. }
  122. ]
  123.  
  124. let option = {};
  125. option.fileName = "品牌形象洞察_偏爱度"; //文件名
  126. option.datas = data.map((v,i)=>{
  127. return {
  128. sheetName: v.sheetName,
  129. sheetData: v.sheetData,
  130. sheetHeader: Object.values(v.contrast),
  131. sheetFilter: Object.keys(v.contrast),
  132. columnWidths: [], // 列宽
  133. }
  134. })
  135. var toExcel = new ExportJsonExcel(option);
  136. toExcel.saveExcel();
  137. loadingMsg.close();
  138. }
  139.  
  140. function urlClick() {
  141. if (target_data) {
  142. loadingMsg = Qmsg.loading("正在导出,请勿重复点击!");
  143. expExcel();
  144. } else {
  145. loadingMsg = Qmsg.error("数据加载失败,请重试");
  146. }
  147. }
  148. })();

QingJ © 2025

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