自動點擊啟用按鈕

此腳本可以檢測並自動點擊變為可用狀態的按鈕。經測試,該腳本在 https://app.runwayml.com/* 頁面上正常運行。

目前為 2024-06-07 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Auto Click Enabled Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.5
  5. // @description 探测并自动点击变为可用状态的按钮
  6. // @author HDR10
  7. // @match https://*/*
  8. // @grant none
  9. // @license Apache License 2.0
  10. // @license-link https://www.apache.org/licenses/LICENSE-2.0
  11.  
  12. // @name:en Auto Click Enabled Button
  13. // @description:en This script detects and automatically clicks buttons that become enabled. It has been tested and works correctly on the https://app.runwayml.com/* page.
  14.  
  15. // @name:zh-CN 自动点击启用按钮
  16. // @description:zh-CN 这个脚本可以探测并自动点击变为可用状态的按钮。该脚本于 https://app.runwayml.com/* 页面测试正常运行。
  17.  
  18. // @name:hi ऑटो क्लिक सक्षम बटन
  19. // @description:hi यह स्क्रिप्ट बटन को पहचानती है और स्वचालित रूप से क्लिक करती है जो सक्षम हो जाते हैं। इसका परीक्षण https://app.runwayml.com/* पृष्ठ पर किया गया है और यह सही ढंग से काम करता है।
  20.  
  21. // @name:fr Bouton de clic automatique activé
  22. // @description:fr Ce script détecte et clique automatiquement sur les boutons qui deviennent activés. Il a été testé et fonctionne correctement sur la page https://app.runwayml.com/*.
  23.  
  24. // @name:ar زر النقر التلقائي عند التمكين
  25. // @description:ar يكتشف هذا البرنامج النصي الأزرار التي تصبح ممكّنة وينقر عليها تلقائيًا. تم اختباره ويعمل بشكل صحيح على صفحة https://app.runwayml.com/*.
  26.  
  27. // @name:bg Автоматично кликване на активиран бутон
  28. // @description:bg Този скрипт открива и автоматично кликва върху бутони, които стават активни. Тестван е и работи правилно на страницата https://app.runwayml.com/*.
  29.  
  30. // @name:ru Автоматическое нажатие на активированные кнопки
  31. // @description:ru Этот скрипт обнаруживает и автоматически нажимает кнопки, которые становятся активными. Он был протестирован и работает правильно на странице https://app.runwayml.com/*.
  32.  
  33. // @name:pt-BR Botão de Clique Automático Habilitado
  34. // @description:pt-BR Este script detecta e clica automaticamente em botões que se tornam habilitados. Ele foi testado e funciona corretamente na página https://app.runwayml.com/*.
  35.  
  36. // @name:id Tombol Klik Otomatis yang Diaktifkan
  37. // @description:id Skrip ini mendeteksi dan mengklik tombol yang menjadi aktif secara otomatis. Skrip ini telah diuji dan berfungsi dengan baik di halaman https://app.runwayml.com/*.
  38.  
  39. // @name:zh-TW 自動點擊啟用按鈕
  40. // @description:zh-TW 此腳本可以檢測並自動點擊變為可用狀態的按鈕。經測試,該腳本在 https://app.runwayml.com/* 頁面上正常運行。
  41. // ==/UserScript==
  42. // ==/UserScript==
  43.  
  44. (function() {
  45. 'use strict';
  46.  
  47. // 创建浮窗
  48. const floatWindow = document.createElement('div');
  49. floatWindow.style.position = 'fixed';
  50. floatWindow.style.bottom = '10px';
  51. floatWindow.style.right = '10px';
  52. floatWindow.style.width = '400px';
  53. floatWindow.style.height = '250px';
  54. floatWindow.style.backgroundColor = 'white';
  55. floatWindow.style.border = '1px solid black';
  56. floatWindow.style.color = 'black';
  57. floatWindow.style.padding = '10px';
  58. floatWindow.style.overflowY = 'auto';
  59. floatWindow.style.zIndex = '10000';
  60. floatWindow.innerHTML = `
  61. <div>
  62. <div id="dragHandle" style="width: 20px; height: 20px; background-color: gray; position: absolute; top: 5px; right: 5px; cursor: move;"></div>
  63. <h3>自动点击变为可用的button</h3>
  64. <p id="statusLabel">自动点击已停止</p>
  65. <button id="startBtn">启用</button>
  66. <button id="stopBtn">停止</button>
  67. <label for="clickLimit">点击几次后停止:</label>
  68. <input type="number" id="clickLimit" value="0" min="0" style="width: 50px;">
  69. <div id="logContainer" style="height: 100px; background-color: white; border: 1px solid black; overflow-y: auto;"></div>
  70. <button id="clearLogBtn">清除log</button>
  71. <button id="minimizeBtn">最小化</button>
  72. </div>
  73. `;
  74. document.body.appendChild(floatWindow);
  75.  
  76. // 创建最小化图标
  77. const minimizeIcon = document.createElement('div');
  78. minimizeIcon.style.position = 'fixed';
  79. minimizeIcon.style.bottom = '10px';
  80. minimizeIcon.style.right = '10px';
  81. minimizeIcon.style.width = '40px';
  82. minimizeIcon.style.height = '40px';
  83. minimizeIcon.style.backgroundColor = 'white';
  84. minimizeIcon.style.border = '1px solid black';
  85. minimizeIcon.style.borderRadius = '50%';
  86. minimizeIcon.style.display = 'flex';
  87. minimizeIcon.style.alignItems = 'center';
  88. minimizeIcon.style.justifyContent = 'center';
  89. minimizeIcon.style.cursor = 'pointer';
  90. minimizeIcon.style.zIndex = '10000';
  91. minimizeIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8 4.41 0 8 3.59 8 8 0 4.41-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"/></svg>`;
  92. minimizeIcon.style.display = 'none';
  93. document.body.appendChild(minimizeIcon);
  94.  
  95. let observer;
  96. let autoClickEnabled = false;
  97. let clickCount = 0;
  98. let clickLimit = 0;
  99.  
  100. document.getElementById('startBtn').addEventListener('click', function() {
  101. autoClickEnabled = true;
  102. clickCount = 0;
  103. clickLimit = parseInt(document.getElementById('clickLimit').value, 10);
  104. document.getElementById('statusLabel').textContent = '自动点击已启用';
  105. document.getElementById('statusLabel').style.color = 'green';
  106. minimizeIcon.style.backgroundColor = 'green';
  107. startObserving();
  108. });
  109.  
  110. document.getElementById('stopBtn').addEventListener('click', function() {
  111. autoClickEnabled = false;
  112. document.getElementById('statusLabel').textContent = '自动点击已停止';
  113. document.getElementById('statusLabel').style.color = 'black';
  114. minimizeIcon.style.backgroundColor = 'white';
  115. stopObserving();
  116. });
  117.  
  118. document.getElementById('clearLogBtn').addEventListener('click', function() {
  119. document.getElementById('logContainer').innerHTML = '';
  120. });
  121.  
  122. document.getElementById('minimizeBtn').addEventListener('click', function() {
  123. floatWindow.style.display = 'none';
  124. minimizeIcon.style.display = 'flex';
  125. });
  126.  
  127. minimizeIcon.addEventListener('click', function() {
  128. floatWindow.style.display = 'block';
  129. minimizeIcon.style.display = 'none';
  130. });
  131.  
  132. function startObserving() {
  133. const config = { attributes: true, childList: true, subtree: true };
  134. observer = new MutationObserver(mutationsList => {
  135. for (let mutation of mutationsList) {
  136. if (mutation.type === 'attributes' && mutation.attributeName === 'disabled') {
  137. const target = mutation.target;
  138. if (target.tagName.toLowerCase() === 'button' && !target.disabled && autoClickEnabled) {
  139. target.click();
  140. clickCount++;
  141. logClick(target);
  142. if (clickLimit > 0 && clickCount >= clickLimit) {
  143. autoClickEnabled = false;
  144. document.getElementById('statusLabel').textContent = '自动点击已停止';
  145. document.getElementById('statusLabel').style.color = 'black';
  146. minimizeIcon.style.backgroundColor = 'white';
  147. stopObserving();
  148. }
  149. }
  150. }
  151. }
  152. });
  153.  
  154. observer.observe(document.body, config);
  155. }
  156.  
  157. function stopObserving() {
  158. if (observer) {
  159. observer.disconnect();
  160. observer = null;
  161. }
  162. }
  163.  
  164. function logClick(target) {
  165. const logContainer = document.getElementById('logContainer');
  166. const timestamp = new Date().toLocaleTimeString();
  167. const logEntry = document.createElement('div');
  168. logEntry.textContent = `${timestamp} - 点击了按钮: ${target.innerText || target.id || 'Unknown'}`;
  169. logContainer.appendChild(logEntry);
  170.  
  171. // 保持日志最多显示10行
  172. while (logContainer.children.length > 10) {
  173. logContainer.removeChild(logContainer.firstChild);
  174. }
  175.  
  176. // 自动滚动到最新日志
  177. logContainer.scrollTop = logContainer.scrollHeight;
  178. }
  179.  
  180. // 拖动浮窗功能
  181. const dragHandle = document.getElementById('dragHandle');
  182. let isDragging = false;
  183. let startX, startY, initialX, initialY;
  184.  
  185. dragHandle.addEventListener('mousedown', function(e) {
  186. isDragging = true;
  187. startX = e.clientX;
  188. startY = e.clientY;
  189. initialX = floatWindow.offsetLeft;
  190. initialY = floatWindow.offsetTop;
  191. document.addEventListener('mousemove', onMouseMove);
  192. document.addEventListener('mouseup', onMouseUp);
  193. });
  194.  
  195. function onMouseMove(e) {
  196. if (isDragging) {
  197. const dx = e.clientX - startX;
  198. const dy = e.clientY - startY;
  199. floatWindow.style.left = initialX + dx + 'px';
  200. floatWindow.style.top = initialY + dy + 'px';
  201. }
  202. }
  203.  
  204. function onMouseUp() {
  205. isDragging = false;
  206. document.removeEventListener('mousemove', onMouseMove);
  207. document.removeEventListener('mouseup', onMouseUp);
  208. }
  209. })();