preLoadFile.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. let owoLoadList = []
  2. function loadCSS (url) {
  3. if (owoLoadList.includes(url)) {
  4. return
  5. }
  6. owoLoadList.push(url)
  7. var link = document.createElement("link");
  8. link.rel = "stylesheet";
  9. link.type = "text/css";
  10. link.href = url;
  11. document.getElementsByTagName("head")[0].appendChild(link);
  12. }
  13. if (document.querySelector('.puge-box')) document.querySelector('.puge-box').outerHTML = ''
  14. setTimeout(() => {
  15. var box = document.getElementsByClassName('puge-box')
  16. if (!box[0]) {
  17. var insertElement = document.createElement("div");
  18. insertElement.style.display = 'none'
  19. insertElement.classList.add('puge-box')
  20. insertElement.style.zIndex = '9665'
  21. insertElement.style.width = '210px'
  22. insertElement.style.height = '300px'
  23. insertElement.style.position = 'fixed'
  24. insertElement.style.right = '0'
  25. insertElement.style.top = '0'
  26. insertElement.style.backgroundColor = 'white'
  27. document.body.appendChild(insertElement);
  28. if (window.pugeCreated) {
  29. window.pugeCreated(insertElement)
  30. window.pugeCreated = null
  31. }
  32. }
  33. }, 1000)
  34. var box = document.getElementsByClassName('puge-menu')
  35. if (!box[0]) {
  36. var insertElement = document.createElement("div");
  37. insertElement.classList.add('puge-menu')
  38. insertElement.innerHTML = `
  39. <div class="puge" style="position: fixed;
  40. width: 40px;
  41. height: 40px;
  42. right: 10px;
  43. bottom: 120px;
  44. z-index: 9666;
  45. 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>
  46. `
  47. document.body.appendChild(insertElement);
  48. }
  49. function owostart () {
  50. const box = document.getElementsByClassName('puge-box')[0]
  51. // alert(box.style.display)
  52. if (box.style.display == 'none') {
  53. box.style.display = 'block'
  54. if (window.pugeCreated) {
  55. window.pugeCreated(document.getElementsByClassName('puge-box')[0])
  56. window.pugeCreated = null
  57. }
  58. } else {
  59. box.style.display = 'none'
  60. }
  61. window.loadingDialog = function () {
  62. return
  63. }
  64. window.alertDialog = function (text) {
  65. window.logBox.add(text)
  66. }
  67. }
  68. function simulateTyping(searchBox, text, callBack) {
  69. if (!searchBox) return;
  70. // 确保搜索框获得焦点
  71. searchBox.focus();
  72. // 模拟逐个字符输入
  73. text.split('').forEach((char, index) => {
  74. setTimeout(() => {
  75. // 创建键盘事件
  76. const keyDownEvent = new KeyboardEvent('keydown', {
  77. key: char,
  78. code: `Key${char.toUpperCase()}`,
  79. bubbles: true
  80. });
  81. const keyPressEvent = new KeyboardEvent('keypress', {
  82. key: char,
  83. bubbles: true
  84. });
  85. const keyUpEvent = new KeyboardEvent('keyup', {
  86. key: char,
  87. bubbles: true
  88. });
  89. // 触发事件
  90. searchBox.dispatchEvent(keyDownEvent);
  91. searchBox.dispatchEvent(keyPressEvent);
  92. // 插入字符
  93. document.execCommand('insertText', false, char);
  94. searchBox.dispatchEvent(keyUpEvent);
  95. // 如果是最后一个字符,触发搜索
  96. if (index === text.length - 1) {
  97. const inputEvent = new Event('input', { bubbles: true });
  98. searchBox.dispatchEvent(inputEvent);
  99. }
  100. }, index * 100 + 500); // 100ms 间隔模拟打字
  101. });
  102. setTimeout(() => {
  103. // 触发所有可能的事件
  104. const events = ['input', 'change', 'keyup', 'keydown', 'keypress', 'blur', 'focus'];
  105. events.forEach(eventType => {
  106. const event = eventType.startsWith('key')
  107. ? new KeyboardEvent(eventType, { bubbles: true })
  108. : new Event(eventType, { bubbles: true });
  109. searchBox.dispatchEvent(event);
  110. });
  111. if (callBack) callBack()
  112. }, text.split('').length * 100);
  113. }
  114. function simulateFullClick(element) {
  115. // 鼠标按下
  116. const mouseDownEvent = new MouseEvent('mousedown', {
  117. view: window,
  118. bubbles: true,
  119. cancelable: true,
  120. buttons: 1
  121. });
  122. // 鼠标抬起
  123. const mouseUpEvent = new MouseEvent('mouseup', {
  124. view: window,
  125. bubbles: true,
  126. cancelable: true,
  127. buttons: 1
  128. });
  129. // 点击事件
  130. const clickEvent = new MouseEvent('click', {
  131. view: window,
  132. bubbles: true,
  133. cancelable: true,
  134. buttons: 1
  135. });
  136. // 按顺序触发事件
  137. element.dispatchEvent(mouseDownEvent);
  138. element.dispatchEvent(mouseUpEvent);
  139. element.dispatchEvent(clickEvent);
  140. }
  141. function searchText(text, sendText) {
  142. const searchBox = document.querySelector('div[contenteditable="true"]');
  143. if (document.querySelector('._ah_y.x1eu8d0j')) {
  144. document.querySelector('._ah_y.x1eu8d0j').click()
  145. }
  146. setTimeout(() => {
  147. simulateTyping(searchBox, text, () => {
  148. setTimeout(() => {
  149. const gridcellList = document.querySelectorAll('.x1n2onr6[role="gridcell"]')
  150. if (gridcellList.length > 0) {
  151. simulateFullClick(gridcellList[0].querySelector('._ak72'))
  152. setTimeout(() => {
  153. simulateTyping(document.querySelectorAll('[aria-placeholder]')[1], sendText, () => {
  154. setTimeout(() => {
  155. document.querySelectorAll('[aria-expanded="false"][aria-label]')[6].click()
  156. }, 1000);
  157. })
  158. }, 2000);
  159. }
  160. }, 2000);
  161. });
  162. }, 1000);
  163. }
  164. window.pugeCreated = function (el) {
  165. el.innerHTML = `
  166. <div class="owo">
  167. <h5>用户名</h5>
  168. <input type="text" id="yhm" value="241176" stored="">
  169. <h5>发送内容</h5>
  170. <textarea id="fsnr">测试</textarea>
  171. <h5>日志输出</h5>
  172. <div class="log-panel" style="height:400px;"></div>
  173. <div style="
  174. display: inline-block;
  175. background-color: #009fe9;
  176. width: 100px;
  177. text-align: center;
  178. margin-top: 10px;
  179. height: 30px;
  180. line-height: 30px;
  181. color: white;
  182. cursor: pointer;
  183. " onclick="window.isrunning = false;">停止</div><div style="
  184. display: inline-block;
  185. background-color: #009fe9;
  186. width: 100px;
  187. text-align: center;
  188. margin-top: 10px;
  189. height: 30px;
  190. line-height: 30px;
  191. color: white;
  192. margin-right: 5px;
  193. cursor: pointer;
  194. " onclick="sendMessage()">启动</div>
  195. </div>`
  196. }
  197. function sendMessage() {
  198. searchText(window.yhm.value, window.fsnr.value)
  199. }