Greasy Fork

AutoLitecoin

Auto login and faucet

目前为 2023-09-29 提交的版本。查看 最新版本

// ==UserScript==
// @name         AutoLitecoin
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto login and faucet
// @author       White
// @match        https://autolitecoin.xyz/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=autolitecoin.xyz
// @grant        none
// ==/UserScript==

(async function() {
    'use strict';

    const handlePageRedirection = () => {
        const url = window.location.href;

        if (url === 'https://autolitecoin.xyz' || url === 'https://autolitecoin.xyz/') {
            window.location.href = 'https://autolitecoin.xyz/login';
        } else if (url === 'https://autolitecoin.xyz/dashboard') {
            window.location.href = 'https://autolitecoin.xyz/faucet';
        }
    };

    const waitForElement = async (selector) => {
        while (!document.querySelector(selector)) {
            await new Promise(resolve => requestAnimationFrame(resolve));
        }
        return document.querySelector(selector);
    };

    const preencherCampos = async () => {
        const [emailInput, passwordInput] = await Promise.all([waitForElement('#email'), waitForElement('#password')]);

        if (emailInput && passwordInput) {
            emailInput.value = 'email';
            passwordInput.value = 'senha';

            await waitForCaptchaCompletion();

            clicarBotaoLogin();
        }
    };

    const clicarBotaoLogin = () => {
        const signInButton = document.querySelector('button.btn-submit.w-100');

        if (signInButton) {
            signInButton.dispatchEvent(new MouseEvent('click'));
        }
    };

    const waitForCaptchaCompletion = async () => {
        while (!(grecaptcha && grecaptcha.getResponse().length > 0)) {
            await new Promise(resolve => setTimeout(resolve, 100));
        }
        clicarBotaoLogin();
    };

    const executeScript = async () => {
        handlePageRedirection();

        if (window.location.href.includes('https://autolitecoin.xyz/login')) {
            await preencherCampos();
        }
    };

    await executeScript();

    let hasClicked = false;

    function mbsolver() {
        const divAntibotLinks = document.querySelectorAll('div.antibotlinks a[style="display: none;"]');
        return divAntibotLinks.length === 3;
    }

    function wasButtonClicked() {
        return localStorage.getItem('buttonClicked') === 'true';
    }

    function setButtonClicked() {
        localStorage.setItem('buttonClicked', 'true');
    }

    function removeButtonClicked() {
        localStorage.removeItem('buttonClicked');
    }

    if (wasButtonClicked()) {
        removeButtonClicked();
        window.location.href = 'https://autolitecoin.xyz/faucet';
    }

    setInterval(function() {
        const grecaptchaResponse = (window.grecaptcha && window.grecaptcha.getResponse) ? window.grecaptcha.getResponse() : null;
        const divAntibotLinks = document.querySelectorAll('div.antibotlinks a[style="display: none;"]');


        if (window.location.href.includes("/faucet") && grecaptchaResponse && grecaptchaResponse.length > 0 && mbsolver() && !wasButtonClicked()) {
            const submitButton = document.querySelector('button.btn.btn-success.btn-lg.claim-button');
            if (submitButton) {
                submitButton.click();
                setButtonClicked();
            }
        }
    }, 3000);
})();