Auto click Claim Button

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

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

  1. // ==UserScript==
  2. // @name Auto click Claim Button
  3. // @namespace AutoClickClaimButton
  4. // @version 1.2
  5. // @description 自動點擊所有帶有 "Claim" 字眼的按鈕,直到按鈕可用為止,並等待 CAPTCHA 解決。
  6. // @author Yueei
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // 檢查 CAPTCHA 是否存在
  16. function checkCaptcha() {
  17. const captchaSelectors = [
  18. "iframe[src*='recaptcha']",
  19. ".g-recaptcha",
  20. ".h-captcha",
  21. ".turnstile",
  22. "[data-sitekey]"
  23. ];
  24.  
  25. const captchaExists = captchaSelectors.some(selector => document.querySelector(selector));
  26.  
  27. if (captchaExists) {
  28. console.log('檢測到 CAPTCHA,等待解決...');
  29. return true; // 若發現 CAPTCHA,返回 true 表示有 CAPTCHA
  30. }
  31.  
  32. return false; // 若無 CAPTCHA,返回 false 允許繼續執行按鈕點擊
  33. }
  34.  
  35. // 自動點擊 Claim 按鈕的函數
  36. function clickClaimButton() {
  37. console.log('檢測並嘗試點擊 Claim 按鈕...');
  38. const buttons = Array.from(document.querySelectorAll("button, a"));
  39. const claimButton = buttons.find(btn => {
  40. const text = btn.textContent.trim().toLowerCase();
  41. return (
  42. text.includes('claim') && // 包含 "claim"
  43. !btn.disabled && // 按鈕未禁用
  44. (
  45. text === 'claim' || // 只有 "claim"
  46. text.includes('claim ') || // "claim " 後有額外字元
  47. text.includes(' claim') // 前面有額外字元
  48. )
  49. );
  50. });
  51.  
  52. if (claimButton) {
  53. claimButton.click();
  54. console.log(`已成功點擊 Claim 按鈕: ${claimButton.textContent.trim()}`);
  55. } else {
  56. console.log('尚未找到可用的 Claim 按鈕,等待...');
  57. }
  58. }
  59.  
  60. // 主函數,定期執行檢查
  61. function startProcess() {
  62. console.log('自動點擊腳本已啟動,正在監控 Claim 按鈕...');
  63. setInterval(() => {
  64. if (!checkCaptcha()) { // 如果沒有 CAPTCHA,嘗試點擊 Claim 按鈕
  65. clickClaimButton();
  66. }
  67. }, 10000); // 每 10 秒執行一次檢查
  68. }
  69.  
  70. // 啟動腳本
  71. startProcess();
  72. })();