自動點擊所有帶有 "Claim" 字眼的按鈕,直到按鈕可用為止,並等待 CAPTCHA 解決。
当前为
// ==UserScript==
// @name Auto click Claim Button
// @namespace AutoClickClaimButton
// @version 1.2
// @description 自動點擊所有帶有 "Claim" 字眼的按鈕,直到按鈕可用為止,並等待 CAPTCHA 解決。
// @author Yueei
// @match *://*/* // 可替換為特定網站 URL
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
// 定義檢查 Claim 按鈕的函數
function clickClaimButton() {
// 找出所有按鈕和鏈接
const buttons = Array.from(document.querySelectorAll("button, a"));
// 篩選出帶有 "Claim" 字眼的按鈕或鏈接
const claimButton = buttons.find(btn =>
btn.textContent.trim().toLowerCase().includes('claim') &&
!btn.disabled // 按鈕必須可點擊
);
if (claimButton) {
claimButton.click(); // 點擊按鈕
console.log('已成功點擊 Claim 按鈕!');
} else {
console.log('尚未找到可用的 Claim 按鈕,等待...');
}
}
// 定義 CAPTCHA 檢查的函數
function checkCaptcha() {
// 定義可能的 CAPTCHA 相關元素或 iframe
const captchaSelectors = [
"iframe[src*='recaptcha']", // reCAPTCHA 相關的 iframe
".g-recaptcha", // reCAPTCHA v2 的容器
".h-captcha", // hCaptcha 的容器
".turnstile", // Turnstile 的容器
"[data-sitekey]", // 其他 CAPTCHA 可能會有的屬性
];
// 查找所有符合選擇器的元素
const captchaElements = captchaSelectors.some(selector => document.querySelector(selector));
if (captchaElements) {
console.log('檢測到 CAPTCHA,等待解決...');
return false; // 若發現 CAPTCHA,暫停點擊動作
}
return true; // 若無 CAPTCHA,允許進行點擊
}
// 主函數,定期執行檢查並點擊
function startProcess() {
setInterval(() => {
if (checkCaptcha()) { // 若 CAPTCHA 已解決,執行點擊動作
clickClaimButton();
}
}, 10000); // 每10秒執行一次檢查
}
// 啟動腳本
startProcess();
})();