Auto Click Enabled Button

This script detects and automatically clicks buttons that become enabled

  1. // ==UserScript==
  2. // @name Auto Click Enabled Button
  3. // @name:zh-CN 自动点击启用按钮
  4. // @name:en Auto Click Enabled Button
  5. // @name:hi ऑटो क्लिक सक्षम बटन
  6. // @name:fr Bouton de clic automatique activé
  7. // @name:ar زر النقر التلقائي عند التمكين
  8. // @name:bg Автоматично кликване на активиран бутон
  9. // @name:ru Автоматическое нажатие на активированные кнопки
  10. // @name:pt-BR Botão de Clique Automático Habilitado
  11. // @name:id Tombol Klik Otomatis yang Diaktifkan
  12. // @name:zh-TW 自動點擊啟用按鈕
  13. // @namespace http://tampermonkey.net/
  14. // @version 2.6
  15. // @description This script detects and automatically clicks buttons that become enabled
  16. // @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.
  17. // @description:zh-CN 这个脚本可以探测并自动点击变为可用状态的按钮。该脚本于 https://app.runwayml.com/* 页面测试正常运行。
  18. // @description:hi यह स्क्रिप्ट बटन को पहचानती है और स्वचालित रूप से क्लिक करती है जो सक्षम हो जाते हैं। इसका परीक्षण https://app.runwayml.com/* पृष्ठ पर किया गया है और यह सही ढंग से काम करता है।
  19. // @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/*.
  20. // @description:ar يكتشف هذا البرنامج النصي الأزرار التي تصبح ممكّنة وينقر عليها تلقائيًا. تم اختباره ويعمل بشكل صحيح على صفحة https://app.runwayml.com/*.
  21. // @description:bg Този скрипт открива и автоматично кликва върху бутони, които стават активни. Тестван е и работи правилно на страницата https://app.runwayml.com/*.
  22. // @description:ru Этот скрипт обнаруживает и автоматически нажимает кнопки, которые становятся активными. Он был протестирован и работает правильно на странице https://app.runwayml.com/*.
  23. // @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/*.
  24. // @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/*.
  25. // @description:zh-TW 此腳本可以檢測並自動點擊變為可用狀態的按鈕。經測試,該腳本在 https://app.runwayml.com/* 頁面上正常運行。
  26. // @author HDR10
  27. // @match https://*/*
  28. // @match https://app.runwayml.com/*
  29. // @grant none
  30. // @license Apache License 2.0
  31. // ==/UserScript==
  32.  
  33. (function() {
  34. 'use strict';
  35.  
  36. // 多语言支持的按钮文本
  37. const texts = {
  38. en: {
  39. title: "Auto Click Enabled Button",
  40. statusStopped: "Auto-clicking stopped",
  41. statusStarted: "Auto-clicking enabled",
  42. start: "Enable",
  43. stop: "Stop",
  44. clickLimit: "Stop after clicking:",
  45. clearLog: "Clear log",
  46. minimize: "Minimize"
  47. },
  48. "zh-CN": {
  49. title: "自动点击启用按钮",
  50. statusStopped: "自动点击已停止",
  51. statusStarted: "自动点击已启用",
  52. start: "启用",
  53. stop: "停止",
  54. clickLimit: "点击几次后停止:",
  55. clearLog: "清除log",
  56. minimize: "最小化"
  57. },
  58. hi: {
  59. title: "ऑटो क्लिक सक्षम बटन",
  60. statusStopped: "स्वचालित क्लिक बंद हो गया",
  61. statusStarted: "स्वचालित क्लिक सक्षम",
  62. start: "सक्षम करें",
  63. stop: "रोकें",
  64. clickLimit: "क्लिक करने के बाद रोकें:",
  65. clearLog: "लॉग साफ़ करें",
  66. minimize: "छोटा करें"
  67. },
  68. fr: {
  69. title: "Bouton de clic automatique activé",
  70. statusStopped: "Clic automatique arrêté",
  71. statusStarted: "Clic automatique activé",
  72. start: "Activer",
  73. stop: "Arrêter",
  74. clickLimit: "Arrêter après avoir cliqué:",
  75. clearLog: "Effacer le journal",
  76. minimize: "Minimiser"
  77. },
  78. ar: {
  79. title: "زر النقر التلقائي عند التمكين",
  80. statusStopped: "توقف النقر التلقائي",
  81. statusStarted: "تمكين النقر التلقائي",
  82. start: "تمكين",
  83. stop: "إيقاف",
  84. clickLimit: "توقف بعد النقر:",
  85. clearLog: "مسح السجل",
  86. minimize: "تصغير"
  87. },
  88. bg: {
  89. title: "Автоматично кликване на активиран бутон",
  90. statusStopped: "Автоматичното кликване е спряно",
  91. statusStarted: "Автоматичното кликване е активирано",
  92. start: "Активирай",
  93. stop: "Спри",
  94. clickLimit: "Спри след кликване:",
  95. clearLog: "Изчисти дневника",
  96. minimize: "Минимизирай"
  97. },
  98. ru: {
  99. title: "Автоматическое нажатие на активированные кнопки",
  100. statusStopped: "Автоклик остановлен",
  101. statusStarted: "Автоклик активирован",
  102. start: "Активировать",
  103. stop: "Остановить",
  104. clickLimit: "Остановить после кликов:",
  105. clearLog: "Очистить журнал",
  106. minimize: "Свернуть"
  107. },
  108. "pt-BR": {
  109. title: "Botão de Clique Automático Habilitado",
  110. statusStopped: "Clique automático parado",
  111. statusStarted: "Clique automático habilitado",
  112. start: "Habilitar",
  113. stop: "Parar",
  114. clickLimit: "Parar após clicar:",
  115. clearLog: "Limpar log",
  116. minimize: "Minimizar"
  117. },
  118. id: {
  119. title: "Tombol Klik Otomatis yang Diaktifkan",
  120. statusStopped: "Klik otomatis dihentikan",
  121. statusStarted: "Klik otomatis diaktifkan",
  122. start: "Aktifkan",
  123. stop: "Hentikan",
  124. clickLimit: "Berhenti setelah mengklik:",
  125. clearLog: "Hapus log",
  126. minimize: "Minimalkan"
  127. },
  128. "zh-TW": {
  129. title: "自動點擊啟用按鈕",
  130. statusStopped: "自動點擊已停止",
  131. statusStarted: "自動點擊已啟用",
  132. start: "啟用",
  133. stop: "停止",
  134. clickLimit: "點擊幾次後停止:",
  135. clearLog: "清除log",
  136. minimize: "最小化"
  137. }
  138. };
  139.  
  140. // 获取浏览器语言,默认为英文
  141. const lang = navigator.language || navigator.userLanguage;
  142. const userLang = lang.startsWith('zh') ? (lang === 'zh-TW' ? 'zh-TW' : 'zh-CN') : (texts[lang] ? lang : 'en');
  143. const t = texts[userLang];
  144.  
  145. // 创建浮窗
  146. const floatWindow = document.createElement('div');
  147. floatWindow.style.position = 'fixed';
  148. floatWindow.style.bottom = '10px';
  149. floatWindow.style.right = '10px';
  150. floatWindow.style.width = '400px';
  151. floatWindow.style.height = '250px';
  152. floatWindow.style.backgroundColor = 'white';
  153. floatWindow.style.border = '1px solid black';
  154. floatWindow.style.color = 'black';
  155. floatWindow.style.padding = '10px';
  156. floatWindow.style.overflowY = 'auto';
  157. floatWindow.style.zIndex = '10000';
  158. floatWindow.style.display = 'none'; // 初始状态为最小化
  159. floatWindow.innerHTML = `
  160. <div>
  161. <div id="dragHandle" style="width: 20px; height: 20px; background-color: gray; position: absolute; top: 5px; right: 5px; cursor: move;"></div>
  162. <h3>${t.title}</h3>
  163. <p id="statusLabel">${t.statusStopped}</p>
  164. <button id="startBtn">${t.start}</button>
  165. <button id="stopBtn">${t.stop}</button>
  166. <label for="clickLimit">${t.clickLimit}</label>
  167. <input type="number" id="clickLimit" value="0" min="0" style="width: 50px;">
  168. <div id="logContainer" style="height: 100px; background-color: white; border: 1px solid black; overflow-y: auto;"></div>
  169. <button id="clearLogBtn">${t.clearLog}</button>
  170. <button id="minimizeBtn">${t.minimize}</button>
  171. </div>
  172. `;
  173. document.body.appendChild(floatWindow);
  174.  
  175. // 创建最小化图标
  176. const minimizeIcon = document.createElement('div');
  177. minimizeIcon.style.position = 'fixed';
  178. minimizeIcon.style.bottom = '10px';
  179. minimizeIcon.style.right = '10px';
  180. minimizeIcon.style.width = '40px';
  181. minimizeIcon.style.height = '40px';
  182. minimizeIcon.style.backgroundColor = 'white';
  183. minimizeIcon.style.border = '1px solid black';
  184. minimizeIcon.style.borderRadius = '50%';
  185. minimizeIcon.style.display = 'flex';
  186. minimizeIcon.style.alignItems = 'center';
  187. minimizeIcon.style.justifyContent = 'center';
  188. minimizeIcon.style.cursor = 'pointer';
  189. minimizeIcon.style.zIndex = '10000';
  190. 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>`;
  191. document.body.appendChild(minimizeIcon);
  192.  
  193. let observer;
  194. let autoClickEnabled = false;
  195. let clickCount = 0;
  196. let clickLimit = 0;
  197.  
  198. document.getElementById('startBtn').addEventListener('click', function() {
  199. autoClickEnabled = true;
  200. clickCount = 0;
  201. clickLimit = parseInt(document.getElementById('clickLimit').value, 10);
  202. document.getElementById('statusLabel').textContent = t.statusStarted;
  203. document.getElementById('statusLabel').style.color = 'green';
  204. minimizeIcon.style.backgroundColor = 'green';
  205. startObserving();
  206. });
  207.  
  208. document.getElementById('stopBtn').addEventListener('click', function() {
  209. autoClickEnabled = false;
  210. document.getElementById('statusLabel').textContent = t.statusStopped;
  211. document.getElementById('statusLabel').style.color = 'black';
  212. minimizeIcon.style.backgroundColor = 'white';
  213. stopObserving();
  214. });
  215.  
  216. document.getElementById('clearLogBtn').addEventListener('click', function() {
  217. document.getElementById('logContainer').innerHTML = '';
  218. });
  219.  
  220. document.getElementById('minimizeBtn').addEventListener('click', function() {
  221. floatWindow.style.display = 'none';
  222. minimizeIcon.style.display = 'flex';
  223. });
  224.  
  225. minimizeIcon.addEventListener('click', function() {
  226. floatWindow.style.display = 'block';
  227. minimizeIcon.style.display = 'none';
  228. });
  229.  
  230. function startObserving() {
  231. const config = { attributes: true, childList: true, subtree: true };
  232. observer = new MutationObserver(mutationsList => {
  233. for (let mutation of mutationsList) {
  234. if (mutation.type === 'attributes' && mutation.attributeName === 'disabled') {
  235. const target = mutation.target;
  236. if (target.tagName.toLowerCase() === 'button' && !target.disabled && autoClickEnabled) {
  237. target.click();
  238. clickCount++;
  239. logClick(target);
  240. if (clickLimit > 0 && clickCount >= clickLimit) {
  241. autoClickEnabled = false;
  242. document.getElementById('statusLabel').textContent = t.statusStopped;
  243. document.getElementById('statusLabel').style.color = 'black';
  244. minimizeIcon.style.backgroundColor = 'white';
  245. stopObserving();
  246. }
  247. }
  248. }
  249. }
  250. });
  251.  
  252. observer.observe(document.body, config);
  253. }
  254.  
  255. function stopObserving() {
  256. if (observer) {
  257. observer.disconnect();
  258. observer = null;
  259. }
  260. }
  261.  
  262. function logClick(target) {
  263. const logContainer = document.getElementById('logContainer');
  264. const timestamp = new Date().toLocaleTimeString();
  265. const logEntry = document.createElement('div');
  266. logEntry.textContent = `${timestamp} - 点击了按钮: ${target.innerText || target.id || 'Unknown'}`;
  267. logContainer.appendChild(logEntry);
  268.  
  269. // 保持日志最多显示10行
  270. while (logContainer.children.length > 10) {
  271. logContainer.removeChild(logContainer.firstChild);
  272. }
  273.  
  274. // 自动滚动到最新日志
  275. logContainer.scrollTop = logContainer.scrollHeight;
  276. }
  277.  
  278. // 拖动浮窗功能
  279. const dragHandle = document.getElementById('dragHandle');
  280. let isDragging = false;
  281. let startX, startY, initialX, initialY;
  282.  
  283. dragHandle.addEventListener('mousedown', function(e) {
  284. isDragging = true;
  285. startX = e.clientX;
  286. startY = e.clientY;
  287. initialX = floatWindow.offsetLeft;
  288. initialY = floatWindow.offsetTop;
  289. document.addEventListener('mousemove', onMouseMove);
  290. document.addEventListener('mouseup', onMouseUp);
  291. });
  292.  
  293. function onMouseMove(e) {
  294. if (isDragging) {
  295. const dx = e.clientX - startX;
  296. const dy = e.clientY - startY;
  297. floatWindow.style.left = initialX + dx + 'px';
  298. floatWindow.style.top = initialY + dy + 'px';
  299. }
  300. }
  301.  
  302. function onMouseUp() {
  303. isDragging = false;
  304. document.removeEventListener('mousemove', onMouseMove);
  305. document.removeEventListener('mouseup', onMouseUp);
  306. }
  307. })();