PEPE Tekcoin Faucet --> usemicrosoft edge --> or brave

Auto-click "Claim Now" after reCAPTCHA

// ==UserScript==
// @name         PEPE Tekcoin Faucet --> usemicrosoft edge --> or brave
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Auto-click "Claim Now" after reCAPTCHA
// @author       👽
// @match        https://tekcoin.top/faucet/currency/pepe*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let lastActionTime = Date.now();
    let claimScheduled = false;

    // Function to check if reCAPTCHA is solved by token
    function isRecaptchaSolved() {
        const token = document.getElementById('g-recaptcha-response');
        return token && token.value.trim() !== '';
    }

    // Function to click Claim Now only if reCAPTCHA is solved
    function clickClaimButton() {
        if (!isRecaptchaSolved() || claimScheduled) return;

        const claimBtn = document.getElementById('subbutt');
        if (claimBtn && !claimBtn.disabled) {
            console.log('Tekcoin: CAPTCHA solved, scheduling Claim Now in 10 seconds...');
            claimScheduled = true;
            setTimeout(() => {
                claimBtn.click();
                lastActionTime = Date.now();
                console.log('Tekcoin: Claim Now button clicked after delay!');
                claimScheduled = false;
            }, 10000); // 10-second delay
        }
    }

    // Function to handle SweetAlert OK button
    function clickOkButton() {
        const okBtn = document.querySelector('button.swal2-confirm.swal2-styled[style*="display: inline-block"]');
        if (okBtn) {
            console.log('Tekcoin: OK popup detected, will click in 5 seconds...');
            setTimeout(() => {
                okBtn.click();
                lastActionTime = Date.now();
                console.log('Tekcoin: OK button clicked!');
            }, 5000);
        }
    }

    // Function to handle "Go Claim" link
    function clickGoClaim() {
        const goClaimBtn = document.querySelector('a.btn.btn-primary[href="https://tekcoin.top/faucet/currency/pepe"]');
        if (goClaimBtn) {
            console.log('Tekcoin: Go Claim button detected, will click in 15 seconds...');
            setTimeout(() => {
                goClaimBtn.click();
                lastActionTime = Date.now();
                console.log('Tekcoin: Go Claim button clicked!');
            }, 15000);
        }
    }

    // Observe DOM changes to detect buttons
    const observer = new MutationObserver(() => {
        clickClaimButton();
        clickOkButton();
        clickGoClaim();
    });
    observer.observe(document.body, { attributes: true, childList: true, subtree: true });

    // Periodically check in case observer misses it
    setInterval(() => {
        clickClaimButton();
        clickOkButton();
        clickGoClaim();
    }, 2000);

    // Refresh page if no action for 1 minute
    setInterval(() => {
        if (Date.now() - lastActionTime > 60000) {
            console.log('Tekcoin: No action for 1 minute, refreshing page...');
            location.reload();
        }
    }, 5000);
})();