TemuTools

Temu auto rob tools

当前为 2023-08-29 提交的版本,查看 最新版本

  1. /*
  2. * @Author: xx
  3. * @Date: 2023-08-25 14:41:40
  4. * @LastEditTime: 2023-08-29 19:00:23
  5. * @Description:
  6. */
  7.  
  8. // ==UserScript==
  9. // @name TemuTools
  10. // @namespace npm/vite-plugin-monkey
  11. // @version 0.0.11
  12. // @author monkey
  13. // @description Temu auto rob tools
  14. // @license MIT
  15. // @icon https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png
  16. // @match https://kuajing.pinduoduo.com/main/order-manage
  17. // @grant GM.addElement
  18. // @grant GM.addStyle
  19. // @grant GM.deleteValue
  20. // @grant GM.getResourceUrl
  21. // @grant GM.getValue
  22. // @grant GM.info
  23. // @grant GM.listValues
  24. // @grant GM.notification
  25. // @grant GM.openInTab
  26. // @grant GM.registerMenuCommand
  27. // @grant GM.setClipboard
  28. // @grant GM.setValue
  29. // @grant GM.xmlHttpRequest
  30. // @grant GM_addElement
  31. // @grant GM_addStyle
  32. // @grant GM_addValueChangeListener
  33. // @grant GM_cookie
  34. // @grant GM_deleteValue
  35. // @grant GM_download
  36. // @grant GM_getResourceText
  37. // @grant GM_getResourceURL
  38. // @grant GM_getTab
  39. // @grant GM_getTabs
  40. // @grant GM_getValue
  41. // @grant GM_info
  42. // @grant GM_listValues
  43. // @grant GM_log
  44. // @grant GM_notification
  45. // @grant GM_openInTab
  46. // @grant GM_registerMenuCommand
  47. // @grant GM_removeValueChangeListener
  48. // @grant GM_saveTab
  49. // @grant GM_setClipboard
  50. // @grant GM_setValue
  51. // @grant GM_unregisterMenuCommand
  52. // @grant GM_webRequest
  53. // @grant GM_xmlhttpRequest
  54. // @run-at document-start
  55. // @grant unsafeWindow
  56. // @grant window.close
  57. // @grant window.focus
  58. // @grant window.onurlchange
  59. // ==/UserScript==
  60.  
  61. console.log("油猴脚本----");
  62.  
  63. let time_waitfor_ok = 1000;
  64. let time_waitfor_next = 1000;
  65.  
  66. let clickIntervals = {}; // 使用对象来存储不同按钮的间隔器
  67. let totalClickTimes = 0;
  68. let adClickIndex = 0;
  69. let adsElements = [];
  70. let links = {};
  71.  
  72. window.onload = function () {
  73. console.log("页面加载完------- DOMContentLoaded");
  74.  
  75. setTimeout(function () {
  76. console.log("增加按钮 ---- ");
  77. addButton();
  78. }, 8000);
  79. };
  80.  
  81. function addButton() {
  82. const addToShippingLinks = document.querySelectorAll('a[data-testid="beast-core-button-link"] span');
  83. addToShippingLinks.forEach(link => {
  84. if (link.textContent === '加入发货台') {
  85. const parentDiv = link.closest('.order-manage_actions___xYyp');
  86. const autoAddButton = document.createElement('a');
  87. autoAddButton.className = 'BTN_outerWrapper_5-72-0 BTN_textPrimary_5-72-0 BTN_small_5-72-0 BTN_outerWrapperLink_5-72-0';
  88. autoAddButton.setAttribute('data-tracking-id', 'custom-autoAddToShipping');
  89. autoAddButton.innerHTML = '<span>自动加入发货台</span>';
  90.  
  91. autoAddButton.addEventListener('click', () => {
  92. let intervalID = Math.random() * 1200;
  93. console.log("点击开始 -- " + intervalID);
  94. links[intervalID] = link;
  95. start(intervalID);
  96. });
  97.  
  98. parentDiv.appendChild(autoAddButton);
  99. }
  100. });
  101. }
  102.  
  103. // 点击确定
  104. function clickOK(intervalID) {
  105. // 实现点击确定的逻辑
  106. console.log("点击确定----- = " + intervalID);
  107. // 查找所有的按钮
  108. const buttons = document.querySelectorAll('button[data-testid="beast-core-button"]');
  109.  
  110. // 遍历按钮,找到包含 "确认" 文本的按钮
  111. buttons.forEach(button => {
  112. const buttonText = button.querySelector('span').textContent;
  113. if (buttonText === '确认') {
  114. console.log('找到确认按钮:', button);
  115. button.click();
  116. //下一次点击
  117. let id = intervalID;
  118. start(id);
  119. }
  120. });
  121. }
  122.  
  123. // 点击加入发货台
  124. function clickRob(intervalID) {
  125.  
  126. // 判断是否已经不可点击 disable了
  127. // 判断是否已经不可点击,如果有 disabled 属性,则直接返回
  128. if (links[intervalID].closest('a').hasAttribute('disabled')) {
  129. console.log('按钮已被禁用,无法继续点击。');
  130. return;
  131. }
  132. console.log("clickRob intervalID == " + intervalID);
  133. links[intervalID].closest('a').click();
  134.  
  135. setTimeout(() => {
  136. let id = intervalID;
  137. clickOK(id);
  138. }, time_waitfor_ok);
  139. }
  140.  
  141. function start(intervalID) {
  142. clearInterval(clickIntervals[intervalID]); // 清除之前的间隔器,以防止多次点击叠加
  143.  
  144. // clickRob(link);
  145.  
  146. time_waitfor_ok = Math.random() * 700 + 500;
  147. time_waitfor_next = Math.random() * 700 + 1000;
  148.  
  149. console.log("intervalID " + intervalID + "随机的okTime = " + time_waitfor_ok + " nextTime = " + time_waitfor_next);
  150. let time = time_waitfor_ok + time_waitfor_next;
  151.  
  152. clickIntervals[intervalID] = setTimeout(() => {
  153. let id = intervalID;
  154. clickRob(id);
  155. }, time);
  156. }