auto faucet Fastfaucet.site

Automatically Login and auto faucet

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
            }
        })();
    }
})();