TemuTools

Temu auto rob tools

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

  1. /*
  2. * @Author: xx
  3. * @Date: 2023-08-25 14:41:40
  4. * @LastEditTime: 2023-08-28 18:29:34
  5. * @Description:
  6. */
  7.  
  8. // ==UserScript==
  9. // @name TemuTools
  10. // @namespace npm/vite-plugin-monkey
  11. // @version 0.0.3
  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.  
  71. window.onload = function () {
  72. console.log("页面加载完------- DOMContentLoaded");
  73.  
  74. setTimeout(function () {
  75. console.log("增加按钮 ---- ");
  76. addButton();
  77. }, 2000);
  78. };
  79.  
  80. function addButton() {
  81. const addToShippingLinks = document.querySelectorAll('a[data-testid="beast-core-button-link"] span');
  82. addToShippingLinks.forEach(link => {
  83. if (link.textContent === '加入发货台') {
  84. const parentDiv = link.closest('.order-manage_actions___xYyp');
  85.  
  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. start(link);
  93. });
  94.  
  95. parentDiv.appendChild(autoAddButton);
  96. }
  97. });
  98. }
  99.  
  100. // 点击确定
  101. function clickOK(link) {
  102. // 实现点击确定的逻辑
  103. console.log("点击确定-----");
  104. // 查找所有的按钮
  105. const buttons = document.querySelectorAll('button[data-testid="beast-core-button"]');
  106.  
  107. // 遍历按钮,找到包含 "确认" 文本的按钮
  108. buttons.forEach(button => {
  109. const buttonText = button.querySelector('span').textContent;
  110. if (buttonText === '确认') {
  111. console.log('找到确认按钮:', button);
  112. button.click();
  113. //下一次点击
  114. start(link);
  115. }
  116. });
  117. }
  118.  
  119. // 点击加入发货台
  120. function clickRob(link) {
  121.  
  122. // 判断是否已经不可点击 disable了
  123. // 判断是否已经不可点击,如果有 disabled 属性,则直接返回
  124. if (link.closest('a').hasAttribute('disabled')) {
  125. console.log('按钮已被禁用,无法继续点击。');
  126. return;
  127. }
  128.  
  129. link.closest('a').click();
  130.  
  131. setTimeout(() => {
  132. clickOK(link);
  133. }, time_waitfor_ok);
  134. }
  135.  
  136. function start(link) {
  137. const buttonKey = link.textContent; // 以按钮的文本内容作为键值,用于区分不同按钮的间隔器
  138. clearInterval(clickIntervals[buttonKey]); // 清除之前的间隔器,以防止多次点击叠加
  139.  
  140. // clickRob(link);
  141.  
  142. time_waitfor_ok = Math.random() * 700 + 200;
  143. time_waitfor_next = Math.random() * 500 + 300;
  144.  
  145. console.log("随机的okTime = " + time_waitfor_ok + " nextTime = " + time_waitfor_next);
  146. let time = time_waitfor_ok + time_waitfor_next;
  147.  
  148. setTimeout(() => {
  149. clickRob(link);
  150. }, time);
  151. }