Auto click Claim Button

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

目前为 2024-12-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Auto click Claim Button
  3. // @namespace AutoClickClaimButton
  4. // @version 1.4
  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. ".cf-turnstile",
  22. "[data-sitekey]",
  23. ];
  24.  
  25. const captchaElements = captchaSelectors.some(selector => document.querySelector(selector));
  26.  
  27. if (captchaElements) {
  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. const buttons = Array.from(document.querySelectorAll("button, a")); // 查找所有按鈕或超連結
  38. const claimButton = buttons.find(btn => {
  39. const text = btn.textContent.trim().toLowerCase(); // 取得按鈕文字並轉小寫
  40. return (
  41. text.includes('claim') && // 包含 "Claim"
  42. !btn.disabled && // 按鈕未禁用
  43. (
  44. text === 'claim' || // 精確匹配 "Claim"
  45. text.includes('claim ') || // "Claim " 後有額外字元
  46. text.includes(' claim') // 前面有額外字元
  47. )
  48. );
  49. });
  50.  
  51. if (claimButton) {
  52. claimButton.click();
  53. console.log(`已成功點擊 Claim 按鈕: ${claimButton.textContent.trim()}`);
  54. } else {
  55. console.log('尚未找到可用的 Claim 按鈕,等待...');
  56. }
  57. }
  58.  
  59. // 主函數,定期執行檢查
  60. function startProcess() {
  61. console.log('自動點擊腳本已啟動,正在監控 Claim 按鈕...');
  62. setInterval(() => {
  63. if (!checkCaptcha()) { // 如果沒有 CAPTCHA,則嘗試點擊 Claim 按鈕
  64. clickClaimButton();
  65. }
  66. }, 10000); // 每 10 秒執行一次檢查
  67. }
  68.  
  69. // 啟動腳本
  70. startProcess();
  71. })();