Full automation faucet (dashboard, captcha, claim cycle)
目前為
// ==UserScript==
// @name Keran Auto Claim (fixed)
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Full automation faucet (dashboard, captcha, claim cycle)
// @author Rubystance
// @license MIT
// @match https://keran.co/dashboard.php
// @match https://keran.co/faucet.php
// @match https://keran.co/captha.php
// @grant none
// ==/UserScript==
(function () {
'use strict';
const log = (...args) => console.log("[KERAN BOT]", ...args);
const forceFocus = () => {
window.addEventListener('blur', () => window.focus());
setInterval(() => window.focus(), 2000);
};
const waitFor = (selector, timeout = 30000) => {
return new Promise((resolve, reject) => {
const interval = 500;
let timeElapsed = 0;
const check = () => {
const el = document.querySelector(selector);
if (el) return resolve(el);
timeElapsed += interval;
if (timeElapsed >= timeout) return reject(`Timeout waiting for ${selector}`);
setTimeout(check, interval);
};
check();
});
};
const waitForCaptchaSolved = async () => {
while (true) {
const hcaptcha = document.querySelector('iframe[src*="hcaptcha.com"]');
const recaptcha = document.querySelector('iframe[src*="recaptcha"]');
const turnstile = document.querySelector('iframe[src*="challenges.cloudflare.com"]');
let solved = false;
if (hcaptcha) {
const isHidden = hcaptcha.closest('[style*="display: none"]');
solved = isHidden;
} else if (recaptcha) {
const recaptchaResponse = document.querySelector('#g-recaptcha-response');
solved = recaptchaResponse && recaptchaResponse.value.trim() !== "";
} else if (turnstile) {
const input = document.querySelector('input[name="cf-turnstile-response"]');
solved = input && input.value.trim() !== "";
} else {
solved = true;
}
if (solved) break;
log("Waiting for captcha to be solved...");
await new Promise(r => setTimeout(r, 1500));
}
};
const runFaucetFlow = async () => {
try {
const claimBtn = await waitFor('button.button.is-link[type="submit"]:not([disabled])');
log("Clicking 'Claim Now!'");
claimBtn.click();
let startTime = Date.now();
const waitForSolveCaptcha = async () => {
while (true) {
const solveBtn = document.querySelector('#submitBtn:not([disabled])');
if (solveBtn && solveBtn.innerText.includes("Solve Captcha")) {
log("Clicking 'Solve Captcha'");
solveBtn.click();
break;
}
const waitingBtn = document.querySelector('#submitBtn[disabled]');
if (waitingBtn && Date.now() - startTime > 20000) {
log("Timed out. Reloading page...");
location.reload();
return;
}
await new Promise(r => setTimeout(r, 1000));
}
};
await waitForSolveCaptcha();
await waitForCaptchaSolved();
const finalClaim = await waitFor('button.button.is-success[type="submit"]');
log("Captcha solved. Clicking final 'Claim Now'...");
finalClaim.click();
setTimeout(() => {
const repeatBtn = document.querySelector('a[href="/faucet.php"]');
if (repeatBtn) {
log("Restarting cycle...");
repeatBtn.click();
}
}, 5000);
} catch (err) {
console.error("Error in faucet flow:", err);
setTimeout(() => location.reload(), 10000);
}
};
const handleCapthaPage = async () => {
try {
log("Detected /captha.php page");
const solveBtn = await waitFor('#submitBtn');
let start = Date.now();
while (!solveBtn.disabled && solveBtn.innerText.includes("Solve Captcha")) {
log("Clicking 'Solve Captcha'");
solveBtn.click();
await new Promise(r => setTimeout(r, 1000));
if (Date.now() - start > 20000) {
log("Solve Captcha stuck. Reloading...");
location.reload();
return;
}
}
await waitForCaptchaSolved();
const finalClaim = await waitFor('button.button.is-success[type="submit"]');
log("Captcha solved. Clicking final 'Claim Now'...");
finalClaim.click();
setTimeout(() => {
const faucetLink = document.querySelector('a[href="/faucet.php"]');
if (faucetLink) {
log("Restarting cycle...");
faucetLink.click();
}
}, 5000);
} catch (e) {
console.error("Error on captha.php:", e);
setTimeout(() => location.reload(), 5000);
}
};
forceFocus();
setTimeout(() => {
log("Global timeout reached. Reloading...");
location.reload();
}, 60000);
if (location.pathname === "/dashboard.php") {
const faucetLink = document.querySelector('a.button.is-normal.is-info[href="/faucet.php"]');
if (faucetLink) {
log("Redirecting to faucet...");
faucetLink.click();
}
}
if (location.pathname === "/faucet.php") {
window.addEventListener('load', () => {
setTimeout(runFaucetFlow, 1000);
});
}
if (location.pathname === "/captha.php") {
window.addEventListener('load', () => {
setTimeout(handleCapthaPage, 1000);
});
}
})();