Auto click Claim Button

自動點擊所有帶有 "Claim" 字眼的按鈕,直到按鈕可用為止,並等待 CAPTCHA 解決。

当前为 2024-12-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Auto click Claim Button
  3. // @namespace AutoClickClaimButton
  4. // @version 1.2
  5. // @description 自動點擊所有帶有 "Claim" 字眼的按鈕,直到按鈕可用為止,並等待 CAPTCHA 解決。
  6. // @author Yueei
  7. // @match *://*/* // 可替換為特定網站 URL
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // 定義檢查 Claim 按鈕的函數
  16. function clickClaimButton() {
  17. // 找出所有按鈕和鏈接
  18. const buttons = Array.from(document.querySelectorAll("button, a"));
  19.  
  20. // 篩選出帶有 "Claim" 字眼的按鈕或鏈接
  21. const claimButton = buttons.find(btn =>
  22. btn.textContent.trim().toLowerCase().includes('claim') &&
  23. !btn.disabled // 按鈕必須可點擊
  24. );
  25.  
  26. if (claimButton) {
  27. claimButton.click(); // 點擊按鈕
  28. console.log('已成功點擊 Claim 按鈕!');
  29. } else {
  30. console.log('尚未找到可用的 Claim 按鈕,等待...');
  31. }
  32. }
  33.  
  34. // 定義 CAPTCHA 檢查的函數
  35. function checkCaptcha() {
  36. // 定義可能的 CAPTCHA 相關元素或 iframe
  37. const captchaSelectors = [
  38. "iframe[src*='recaptcha']", // reCAPTCHA 相關的 iframe
  39. ".g-recaptcha", // reCAPTCHA v2 的容器
  40. ".h-captcha", // hCaptcha 的容器
  41. ".turnstile", // Turnstile 的容器
  42. "[data-sitekey]", // 其他 CAPTCHA 可能會有的屬性
  43. ];
  44.  
  45. // 查找所有符合選擇器的元素
  46. const captchaElements = captchaSelectors.some(selector => document.querySelector(selector));
  47.  
  48. if (captchaElements) {
  49. console.log('檢測到 CAPTCHA,等待解決...');
  50. return false; // 若發現 CAPTCHA,暫停點擊動作
  51. }
  52.  
  53. return true; // 若無 CAPTCHA,允許進行點擊
  54. }
  55.  
  56. // 主函數,定期執行檢查並點擊
  57. function startProcess() {
  58. setInterval(() => {
  59. if (checkCaptcha()) { // 若 CAPTCHA 已解決,執行點擊動作
  60. clickClaimButton();
  61. }
  62. }, 10000); // 每10秒執行一次檢查
  63. }
  64.  
  65. // 啟動腳本
  66. startProcess();
  67. })();