preLoadFile.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // 监听拦截到的数据
  2. window.dataList = [
  3. ["昵称","发布时间","ID","时长","粉丝","关注","关注率","喜欢","喜欢率","热度","标题"]
  4. ]
  5. window.onInterceptedData = function (data) {
  6. window.systemInfo = data
  7. if (data.url.includes('https://douhot.douyin.com/douhot/v1/material/video_billboard')) {
  8. const dataTemp = JSON.parse(data.responseBody)
  9. console.log(dataTemp)
  10. dataTemp.data.objs.forEach(element => {
  11. window.dataList.push([element.nick_name, element.publish_time, element.item_id, element.item_duration, element.fans_cnt, element.follow_cnt, element.follow_rate, element.like_cnt, element.like_rate, element.score, element.item_title])
  12. });
  13. loadData()
  14. }
  15. };
  16. let owoLoadList = []
  17. function loadCSS (url) {
  18. if (owoLoadList.includes(url)) {
  19. return
  20. }
  21. owoLoadList.push(url)
  22. var link = document.createElement("link");
  23. link.rel = "stylesheet";
  24. link.type = "text/css";
  25. link.href = url;
  26. document.getElementsByTagName("head")[0].appendChild(link);
  27. }
  28. setTimeout(() => {
  29. var box = document.getElementsByClassName('puge-box')
  30. if (!box[0]) {
  31. var insertElement = document.createElement("div");
  32. insertElement.style.display = 'none'
  33. insertElement.classList.add('puge-box')
  34. insertElement.style.zIndex = '9665'
  35. insertElement.style.width = '300px'
  36. insertElement.style.height = '560px'
  37. insertElement.style.position = 'fixed'
  38. insertElement.style.right = '0'
  39. insertElement.style.top = '0'
  40. insertElement.style.fontSize = '18px'
  41. insertElement.style.lineHeight = '30px'
  42. insertElement.style.padding = '10px'
  43. insertElement.style.backgroundColor = 'white'
  44. document.body.appendChild(insertElement);
  45. if (window.pugeCreated) {
  46. window.pugeCreated(insertElement)
  47. window.pugeCreated = null
  48. }
  49. }
  50. }, 1000)
  51. var box = document.getElementsByClassName('puge-menu')
  52. if (!box[0]) {
  53. var insertElement = document.createElement("div");
  54. insertElement.classList.add('puge-menu')
  55. insertElement.innerHTML = `
  56. <div class="puge" style="position: fixed;
  57. width: 40px;
  58. height: 40px;
  59. right: 10px;
  60. bottom: 120px;
  61. z-index: 9666;
  62. color: white;" onclick="owostart()"><svg t="1619252746615" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="19612" width="40" height="40"><path d="M622.7968 89.7024l60.1088 124.1088c15.9744 36.0448 52.0192 60.1088 92.16 66.048l134.144 20.0704c100.1472 14.0288 138.1376 136.192 68.096 208.2816l-98.0992 94.1056c-28.0576 28.0576-42.0864 68.096-36.0448 106.0864l22.016 134.144c15.9744 100.1472-86.1184 174.1824-176.2304 128.2048l-120.1152-62.0544c-36.0448-18.0224-76.0832-18.0224-112.128 0L334.4384 972.8c-90.112 46.08-192.2048-28.0576-176.2304-128.2048l22.016-134.144c7.9872-40.0384-6.0416-80.0768-36.0448-106.0864L46.08 508.2112c-72.0896-72.0896-32.0512-192.2048 68.096-208.2816l134.144-20.0704c40.0384-6.0416 74.1376-30.0032 92.16-66.048l60.1088-124.1088c50.0736-90.112 176.2304-90.112 222.208 0" fill="#FED44A" p-id="19613"></path><path d="M404.5824 89.7024l-60.1088 124.1088c-15.9744 36.0448-52.0192 60.1088-92.16 66.048l-134.144 20.0704c-62.0544 10.0352-102.0928 60.1088-104.1408 112.128 18.0224-98.0992 220.2624-22.016 312.4224-14.0288 94.1056 10.0352 120.1152-74.1376 120.1152-74.1376s20.0704-100.1472 44.032-226.304c18.0224-102.0928 86.1184-58.0608 110.1824-40.0384C544.768-0.4096 444.6208 11.6736 404.5824 89.7024" fill="#FFDE73" p-id="19614"></path><path d="M574.7712 784.5888c-74.1376-50.0736-140.1856 0-140.1856 0S362.496 848.6912 278.4256 928.768c-86.1184 80.0768-118.1696-33.9968-118.1696-33.9968 18.0224 72.0896 102.0928 116.1216 174.1824 76.0832l122.1632-62.0544c36.0448-18.0224 76.0832-18.0224 112.128 0L690.8928 972.8c56.1152 30.0032 118.1696 11.9808 152.1664-32.0512 2.048-7.9872 3.9936-14.0288 7.9872-20.0704-67.9936 66.1504-200.192-86.016-276.2752-136.0896" fill="#FEC54A" p-id="19615"></path><path d="M466.6368 103.7312c15.9744 3.9936 26.0096 18.0224 22.016 36.0448l-28.0576 126.1568c-3.9936 15.9744-18.0224 26.0096-36.0448 22.016-15.9744-3.9936-26.0096-18.0224-22.016-36.0448l28.0576-128.2048c3.9936-15.9744 20.0704-23.9616 36.0448-19.968" fill="#FFF2CA" p-id="19616"></path><path d="M375.3984 530.8416c-29.2864 0-53.0432-18.7392-53.0432-41.984 0-23.1424 23.7568-41.984 53.0432-41.984s53.0432 18.7392 53.0432 41.984c0 23.1424-23.7568 41.984-53.0432 41.984z m260.9152 0c-29.2864 0-53.0432-18.7392-53.0432-41.984 0-23.1424 23.7568-41.984 53.0432-41.984s53.0432 18.7392 53.0432 41.984c0 23.1424-23.7568 41.984-53.0432 41.984z m-190.464 74.6496c-2.56-3.6864-3.3792-8.192-2.56-12.4928 0.9216-4.3008 3.584-8.0896 7.2704-10.4448 7.8848-5.12 18.432-3.072 23.8592 4.608 12.288 17.7152 26.2144 25.8048 43.1104 25.8048s30.8224-8.0896 43.1104-25.8048c5.4272-7.68 15.9744-9.728 23.8592-4.608 3.7888 2.3552 6.4512 6.144 7.2704 10.4448 0.9216 4.3008 0 8.9088-2.56 12.4928-18.3296 26.5216-42.7008 40.6528-71.7824 40.6528-28.8768-0.1024-53.248-14.1312-71.5776-40.6528z m0 0" fill="#92410E" p-id="19617"></path></svg></div>
  63. `
  64. document.body.appendChild(insertElement);
  65. }
  66. function clearData() {
  67. window.dataList = [
  68. ["昵称","发布时间","ID","时长","粉丝","关注","关注率","喜欢","喜欢率","热度","标题"]
  69. ]
  70. loadData()
  71. }
  72. function loadData() {
  73. window.yhqd.innerText = `已获取数据数量:${window.dataList.length - 1}`
  74. }
  75. // 保存CSV
  76. function fake_click(obj) {
  77. var ev = document.createEvent("MouseEvents");
  78. ev.initMouseEvent(
  79. "click", true, false, window, 0, 0, 0, 0, 0
  80. , false, false, false, false, 0, null
  81. );
  82. obj.dispatchEvent(ev);
  83. }
  84. function download(name, data) {
  85. var urlObject = window.URL || window.webkitURL || window;
  86. var downloadData = new Blob([data]);
  87. var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  88. save_link.href = urlObject.createObjectURL(downloadData);
  89. save_link.download = name;
  90. fake_click(save_link);
  91. }
  92. function saveCSV (name, data) {
  93. let saveData = ''
  94. data.forEach(element => {
  95. if (element) {
  96. saveData += element.join(',')
  97. saveData += '\r\n'
  98. }
  99. });
  100. var urlObject = window.URL || window.webkitURL || window;
  101. var downloadData = new Blob(['\ufeff' + saveData], { type: 'text/csv,charset=UTF-8'});
  102. var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  103. save_link.href = urlObject.createObjectURL(downloadData);
  104. save_link.download = name;
  105. fake_click(save_link);
  106. }
  107. function saveData() {
  108. saveCSV ("output.csv", window.dataList)
  109. }
  110. function owostart () {
  111. const box = document.getElementsByClassName('puge-box')[0]
  112. // alert(box.style.display)
  113. if (box.style.display == 'none') {
  114. box.style.display = 'block'
  115. if (window.pugeCreated) {
  116. window.pugeCreated(document.getElementsByClassName('puge-box')[0])
  117. window.pugeCreated = null
  118. }
  119. } else {
  120. box.style.display = 'none'
  121. }
  122. window.loadingDialog = function () {
  123. return
  124. }
  125. }
  126. function logPanel (el, max) {
  127. if (el) {
  128. el.innerHTML = '<ul class="log-panel-w" style="height:300px;overflow: auto;"></ul>'
  129. setTimeout(() => {
  130. this.$el = el.querySelector('.log-panel-w')
  131. }, 0);
  132. }
  133. this.max = max || 100
  134. this.list = []
  135. this.add = function (text) {
  136. if (!text) text = ''
  137. var time = new Date();
  138. let hours = time.getHours()
  139. if (hours <= 9) hours = '0' + hours
  140. let minutes = time.getMinutes()
  141. if (minutes <= 9) minutes = '0' + minutes
  142. let seconds = time.getSeconds()
  143. if (seconds <= 9) seconds = '0' + seconds
  144. this.list.push([`${hours}:${minutes}:${seconds}`, text])
  145. if (this.list.length > this.max) {
  146. this.list = this.list.slice(1)
  147. }
  148. this.make()
  149. }
  150. this.make = function () {
  151. let newHtml = ''
  152. for (let index = this.list.length - 1; index >= 0; index--) {
  153. const element = this.list[index];
  154. newHtml += `<li><span>${element[0]}</span>${element[1]}</li>`
  155. }
  156. setTimeout(() => {
  157. this.$el.innerHTML = newHtml
  158. }, 0);
  159. }
  160. }
  161. setTimeout(() => {
  162. if (document.querySelector('.puge-box')) document.querySelector('.puge-box').innerHTML = `
  163. <h5 style="color:black;" id="yhqd">已获取数据数量:0</h5>
  164. <div class="owo button" onclick="clearData();" style=" background-color: #009fe9; text-align: center; line-height: 40px; margin-bottom:2px;">清理数据</div>
  165. <div class="owo button" onclick="saveData();" style=" background-color: #009fe9; text-align: center; line-height: 40px; margin-bottom:2px;">导出数据</div>
  166. `
  167. }, 2000);