Greasy Fork

Keran.co and Bagi.co.in auto faucet

input Email for automate faucet interactions

目前为 2024-09-27 提交的版本。查看 最新版本

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

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

    const email = cfg.get('Email');
    let currentReferralId = '';

    function determineSiteAndReferralId() {
        if (window.location.href.includes('bagi.co.in')) {
            currentReferralId = '65307';
        } else if (window.location.href.includes('keran.co')) {
            currentReferralId = '69657';
        }
    }

    function showEmailWarning() {
        alert("Please input your Email in the configuration menu.");
    }

    function isLoggedIn() {
        return document.querySelector('.user-dashboard') !== null;
    }

    function redirectToReferralIfNecessary() {
        const currentUrl = window.location.pathname;
        const queryParams = window.location.search;
        if (!isLoggedIn() && (currentUrl === '/' || currentUrl === '/index.php')) {
            if (!queryParams.includes('ref=')) {
                window.location.search = `?ref=${currentReferralId}`;
            }
        }
    }

    function redirectFromDashboard() {
        if (window.location.pathname.includes('/dashboard.php')) {
            window.location.href = '/faucet.php';
        }
    }

    function reloadIfAdditionalUrlExists() {
        const currentPath = window.location.pathname;
        const hasQueryString = window.location.search.length > 0;
        const hasHash = window.location.hash.length > 0;
        if (currentPath.includes('/faucet.php') && (hasQueryString || hasHash)) {
            window.location.href = '/faucet.php';
        }
    }

    function clickGetStartedFirst() {
        const button = document.querySelector('button[data-target="#myModal"]');
        if (button) {
            button.click();
            setTimeout(waitForModal, 1000);
        }
    }

    function waitForModal() {
        const modal = document.querySelector('.modal-card');
        if (modal) {
            fillEmail();
        } else {
            setTimeout(waitForModal, 500);
        }
    }

    function fillEmail() {
        const emailInput = document.querySelector('input[name="address"]');
        if (emailInput && email) {
            emailInput.value = email;
            setTimeout(waitForRecaptchaAndClick, 2000);
        }
    }

    function checkRecaptcha() {
        if (typeof grecaptcha !== 'undefined') {
            return grecaptcha.getResponse().length > 0;
        }
        return false;
    }

    function clickGetStarted() {
        const button = document.querySelector('button.button.is-success[type="submit"]');
        if (button) {
            button.click();
        }
    }

    function clickClaimNow() {
        const claimButton = document.querySelector('button.button.is-info[type="submit"]');
        if (claimButton) {
            claimButton.click();
        }
    }

    function clickLinkButton() {
        const linkButton = document.querySelector('a.button.is-info[href="https://bagi.co.in/faucet.php"]');
        if (linkButton) {
            linkButton.click();
        }
    }

    function showModal() {
        const modal = document.querySelector('#myModal');
        if (modal) {
            modal.classList.add('is-active');
        }
    }

    function redirectIfButtonsDisabledOnFaucetPage() {
        const currentPath = window.location.pathname;
        if (currentPath.includes('/faucet.php')) {
            const buttons = document.querySelectorAll('button');
            let allDisabled = true;

            buttons.forEach(button => {
                if (!button.disabled) {
                    allDisabled = false;
                }
            });

            if (allDisabled) {
                if (window.location.href.includes('keran.co')) {
                    window.location.href = 'https://bagi.co.in/faucet.php';
                } else if (window.location.href.includes('bagi.co.in')) {
                    window.location.href = 'https://keran.co/faucet.php';
                }
            }
        }
    }

    const interval = setInterval(() => {
        if (checkRecaptcha()) {
            clickGetStarted();
            clearInterval(interval);
        }
    }, 1000);

    document.addEventListener('DOMContentLoaded', function() {
        if (!email || email.trim() === '') {
            showEmailWarning();
            return;
        }

        determineSiteAndReferralId();
        redirectToReferralIfNecessary();
        redirectFromDashboard();
        reloadIfAdditionalUrlExists();

        if (window.location.pathname.includes('/faucet.php')) {
            clickClaimNow();
        }

        clickLinkButton();
        showModal();
        redirectIfButtonsDisabledOnFaucetPage();

        setTimeout(() => {
            clickGetStartedFirst();
        }, 5000);
    });

})();

// @grant        window.onurlchange
// @grant        GM_registerMenuCommand
// @require      https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @license      Copyright OjoNgono
// ==/UserScript==

(function() {
    'use strict';

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

    const email = cfg.get('Email'); 
    let currentReferralId = ''; 

    function determineSiteAndReferralId() {
        if (window.location.href.includes('bagi.co.in')) {
            currentReferralId = '65307'; 
        } else if (window.location.href.includes('keran.co')) {
            currentReferralId = '69657'; 
        }
    }

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

    function isAltchaChecked() {
        const altchaCheckbox = document.getElementById('altcha_checkbox');
        return altchaCheckbox && altchaCheckbox.checked;
    }

    function isReCAPTCHAChecked() {
        const recaptchaCheckbox = document.querySelector('.g-recaptcha-response');
        return recaptchaCheckbox && recaptchaCheckbox.value.trim().length > 0;
    }

    function clickCheckbox() {
        const checkbox = document.querySelector('input[type="checkbox"]');
        if (checkbox && !checkbox.checked) {
            checkbox.click();
        }
    }

    const interval = setInterval(() => {
        if (document.querySelector('input[type="checkbox"]') !== null) {
            clickCheckbox();
            clearInterval(interval);
        }
    }, 2000);

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

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

    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 redirectToAlternateSite() {
        if (window.location.href.includes('bagi.co.in')) {
            window.location.href = 'https://keran.co';
        } else if (window.location.href.includes('keran.co')) {
            window.location.href = 'https://bagi.co.in';
        }
    }

    onDocumentReady(function() {

        determineSiteAndReferralId(); 

        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 && isReCAPTCHAChecked()) {
                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()) {
                    redirectToAlternateSite();
                }
                setTimeout(function() { window.location.reload(); }, 60000);
            }, 5000);
            setTimeout(function refresh() {
                window.location.reload();
            }, 600000 + Math.floor(Math.random() * 60000) + 20000); // Set a fixed interval of 10 minutes
        }

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

        if (window.location.href === 'https://bagi.co.in' || window.location.href === 'https://bagi.co.in/' || window.location.href === 'https://bagi.co.in/index.php') {
            setTimeout(function() {
                if (location.search !== `?ref=65307`) {
                    location.search = `?ref=65307`;
                }
            }, 2000);
        } else if (window.location.href === 'https://keran.co' || window.location.href === 'https://keran.co/' || window.location.href === 'https://keran.co/index.php') {
            setTimeout(function() {
                if (location.search !== `?ref=69657`) {
                    location.search = `?ref=69657`;
                }
            }, 2000);
        }

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

    });

})();