Greasy Fork

Greasy Fork is available in English.

Bagi and Keran Auto Faucet

input Email for automate faucet interactions

当前为 2024-06-27 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bagi and Keran Auto Faucet
// @namespace    Auto click faucet
// @version      0.1
// @description  input Email for automate faucet interactions
// @author       Ojo Ngono
// @match        *://bagi.co.in/*
// @match        *://keran.co/*
// @grant        unsafeWindow
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @grant        window.onurlchange
// @grant        GM_registerMenuCommand
// @require      https://update.greasyfork.icu/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @license      Copyright OjoNgono
// ==/UserScript==

(function() {
    'use strict';

    const cfg = new MonkeyConfig({
        title: 'FaucetPay Configuration',
        menuCommand: true,
        params: {
            Email: {
                label: "EmailFaucetpay",
                type: "text",
                default: ''
            },
        }
    });

    const email = cfg.get('Email'); // Get the configured email
    const intervalclaim = 10; // Don't change it
    const check_address = 'https://bagi.co.in';
    const newReferralId = '69657'; // New referral ID
    const newSiteURL = 'https://keran.co'; // New site URL

    function onDocumentReady(fn) {
        if (document.readyState !== "loading") {
            fn();
        } else {
            document.addEventListener("DOMContentLoaded", fn);
        }
    }

    function clickCheckbox() {
        // Select the checkbox using its id
        const checkbox = document.getElementById('altcha_checkbox');
        if (checkbox && !checkbox.checked) {
            checkbox.click();
        }
    }

      // Try to click the checkbox every 2 seconds until it is clicked
        const interval = setInterval(() => {
            if (document.getElementById('altcha_checkbox') !== null) {
                clickCheckbox();
                clearInterval(interval);
            }
        }, 2000);

    // Function to check if altcha checkbox is checked
    function isAltchaChecked() {
        const altchaCheckbox = document.getElementById('altcha_checkbox');
        return altchaCheckbox && altchaCheckbox.checked;
    }

    // Function to click the modal button
    function clickModalButton() {
        let modalButton = document.querySelector("button[data-target='#myModal']");
        if (modalButton) {
            modalButton.click();
        }
    }

    // Function to click the submit button
    function clickSubmitButton() {
        let submitButton = document.querySelector("button[type='submit']");
        if (submitButton && isAltchaChecked()) {
            submitButton.click();
        }
    }

    // Function to click the "Claim Now!" button
    function clickClaimNowButton() {
        let buttons = document.querySelectorAll("button.button.is-info[type='submit']");
        for (let button of buttons) {
            if (button.textContent.trim() === 'Claim Now!') {
                button.click();
                return true;
            }
        }
        return false;
    }

    // Function to redirect to new site if no claim button found
    function redirectToNewSite() {
        window.location.href = newSiteURL;
    }

    onDocumentReady(function() {

        let login = setInterval(function() {
            let card_md = document.querySelector("#myModal.is-active");
            let emailfield = document.querySelector("input[type='email']");
            let button = document.querySelector("button[type='submit']");
            if (card_md && emailfield && emailfield.value !== email) {
                emailfield.value = email;
            }
            if (emailfield.value === email && isCaptchaChecked()) {
                button.click();
                clearInterval(login);
            }
        }, 5000);

        if (window.location.href.includes('captha')) {
            let claim = setInterval(function() {
                clickModalButton();
                clickSubmitButton();
                if (document.querySelector("button[type='submit']")) {
                    setTimeout(function() { window.location.reload(); }, 50000);
                    clearInterval(claim);
                }
            }, 5000);

            let claim2 = setInterval(function() {
                let altcha = document.querySelector("input[name='cf-altcha-response']");
                clickModalButton();
                clickSubmitButton();
                if (document.querySelector("button[type='submit']") && altcha && altcha.value.length > 0) {
                    setTimeout(function() { window.location.reload(); }, 60000);
                    clearInterval(claim2);
                }
            }, 5000);
        }

        if (window.location.href.includes('faucet')) {
            setTimeout(function() {
                if (!clickClaimNowButton()) {
                    redirectToNewSite();
                }
                setTimeout(function() { window.location.reload(); }, 60000);
            }, 5000);
            setTimeout(function refresh() {
                window.location.reload();
            }, intervalclaim * 60000 + Math.floor(Math.random() * 60000) + 20000);
        }

        if (window.location.href.includes('dashboard')) {
            setTimeout(function() {
                location.href = 'faucet.php';
            }, 5000);
        }

        if (window.location.href === (check_address) || window.location.href === (check_address + '/') || window.location.href === (check_address + '/index.php')) {
            setTimeout(function() {
                if (location.search !== `?ref=${newReferralId}`) {
                    location.search = `?ref=${newReferralId}`;
                }
            }, 2000);
        }

        if (location.search === `?ref=${newReferralId}`) {
            setTimeout(function() {
                clickModalButton();
                setTimeout(function() { window.location.reload(); }, 60000);
            }, 3000);
        }

        setTimeout(function() {
            let alertMsg = document.querySelector("div.message-body");
            if (alertMsg && alertMsg.innerText.includes("was sent")) {
                location.reload();
            }
        }, 5000);

    });

})();