Auto Claim Earncryptowrs

Autofills email, waits for CAPTCHA and automates LTC claim on dashboard and faucet pages.

// ==UserScript==
// @name         Auto Claim Earncryptowrs
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Autofills email, waits for CAPTCHA and automates LTC claim on dashboard and faucet pages.
// @author       Rubystance
// @license      MIT
// @match        https://earncryptowrs.in/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const email = "YOUR_FAUCETPAY_EMAIL_HERE"; // <<== Replace this with your FaucetPay email

    function waitForElement(selector, timeout = 10000) {
        return new Promise((resolve, reject) => {
            const intervalTime = 100;
            let elapsed = 0;
            const interval = setInterval(() => {
                const el = document.querySelector(selector);
                if (el) {
                    clearInterval(interval);
                    resolve(el);
                } else if (elapsed >= timeout) {
                    clearInterval(interval);
                    reject(`Element ${selector} not found after ${timeout}ms.`);
                }
                elapsed += intervalTime;
            }, intervalTime);
        });
    }

    async function autoLogin() {
        if (window.location.pathname === "/" || window.location.pathname === "/index") {
            try {
                const input = await waitForElement('input[name="wallet"]');
                input.value = email;

                const observer = new MutationObserver((mutations, obs) => {
                    const verificationMessage = document.querySelector('.iconcaptcha-modal__body-title');
                    if (verificationMessage && verificationMessage.textContent.includes("Verification complete")) {
                        const loginBtn = document.querySelector('button[type="submit"]');
                        if (loginBtn) {
                            loginBtn.click();
                            obs.disconnect();
                        }
                    }
                });

                observer.observe(document.body, { childList: true, subtree: true });

            } catch (e) {
                console.error("Error in autoLogin:", e);
            }
        }
    }

    async function goToFaucetPage() {
        if (window.location.pathname === "/app/dashboard") {
            const claimLink = await waitForElement('a[href*="/app/faucet?currency=LTC"]');
            claimLink.click();
        }
    }

    async function autoClaim() {
        if (window.location.pathname.startsWith("/app/faucet")) {
            const observer = new MutationObserver((mutations, obs) => {
                const verificationMessage = document.querySelector('.iconcaptcha-modal__body-title');
                if (verificationMessage && verificationMessage.textContent.includes("Verification complete")) {
                    const claimBtn = document.querySelector('button.claim-button');
                    if (claimBtn) {
                        claimBtn.click();
                        obs.disconnect();
                    }
                }
            });

            observer.observe(document.body, { childList: true, subtree: true });
        }
    }

    window.addEventListener('load', () => {
        autoLogin();
        goToFaucetPage();
        autoClaim();
    });

})();