auto faucet Fastfaucet.site

Automatically Login and auto faucet

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name             auto faucet Fastfaucet.site
// @namespace       tampermonkey 
// @version         0.1
// @description     Automatically Login and auto faucet
// @author          alialigood
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_addStyle
// @grant           GM_registerMenuCommand
// @match           https://fastfaucet.site/*
// @icon            https://i.ibb.co/XJSPdz0/large.png
// ==/UserScript==

(function () {
    'use strict';

    // Manually set your email address here
    const email = '[email protected]'; // Replace with your email

    window.addEventListener('load', () => {
        console.log("Script loaded!");

        if (!email) {
            enforceLogoutWithWarning();
            return;
        }
        if (!isValidEmail(email)) {
            alert('Invalid email address. Please check your configuration.');
            enforceLogoutWithWarning();
            return;
        }

        if (isLoggedIn()) {
            if (window.location.href === "https://fastfaucet.site/") {
                window.location.replace("https://fastfaucet.site/faucet/currency/dgb");
            }
            return;
        }

        setTimeout(() => {
            enforceReferralUrl(() => {
                fillEmailField(email);
                setTimeout(() => {
                    clickLoginButton();
                }, 2000);
            });
        }, 1000);
    });

    function isLoggedIn() {
        const userDropdown = document.querySelector('.nav-item.dropdown.no-arrow');
        const userIcon = document.querySelector('i.fas.fa-user-circle.fa-2x');
        return userDropdown && userIcon;
    }

    function isValidEmail(email) {
        const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
        return emailRegex.test(email);
    }

    function enforceLogoutWithWarning() {
        if (isLoggedIn()) {
            alert('Please enter your email in the settings menu before using MY SCRIPT.');
            const logoutButton = document.querySelector('a[href="https://fastfaucet.site/auth/logout"]');
            if (logoutButton) {
                logoutButton.click();
            } else {
                window.location.replace("https://fastfaucet.site/auth/logout");
            }
        }
    }

    function enforceReferralUrl(callback) {
        if (!window.location.href.includes("?r=788")) {
            window.location.replace("https://fastfaucet.site/?r=788");
            setTimeout(callback, 1000);
        } else {
            callback();
        }
    }

    function fillEmailField(email) {
        const emailInput = document.querySelector('input[type="email"]');
        if (emailInput) {
            emailInput.value = email;
            emailInput.dispatchEvent(new Event('input', { bubbles: true }));
        }
    }

    function clickLoginButton() {
        const loginButton = document.querySelector('button[type="submit"].btn-user');
        if (loginButton) loginButton.click();
    }

    function checkAndClickTryAgain() {
        const networkErrorMessage = document.querySelector('h2.title-xl-grad');
        const tryAgainButton = document.querySelector('.btn.btn-primary');
        if (networkErrorMessage && tryAgainButton && networkErrorMessage.textContent.trim() === "Network Error") {
            tryAgainButton.click();
        }
    }

    const observer = new MutationObserver(() => {
        checkAndClickTryAgain();
    });

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

    function clickOkButtonAfterDelay() {
        const okButton = document.querySelector('.swal2-confirm');
        if (okButton) {
            setTimeout(() => {
                okButton.click();
            }, 2000);
        }
    }

    clickOkButtonAfterDelay();
})();

(function() {
    if (window.location.href.includes("https://fastfaucet.site/faucet/currency/")) {
        (function() {
            if (document.getElementById("form-captcha") === null) {
                setTimeout(function() {
                    document.getElementsByTagName("form")[0].submit();
                }, 1000);
            }
        })();
    }
})();