Greasy Fork is available in English.

Startoshi.com AutoClaim

Login otomatis, scroll ke Turnstile, dan klaim dengan jeda

// ==UserScript==
// @name             Startoshi.com AutoClaim
// @namespace        http://tampermonkey.net/
// @version          0.2
// @description      Login otomatis, scroll ke Turnstile, dan klaim dengan jeda
// @author           Ojo Ngono
// @match            https://startoshi.com/*
// @grant            GM_getValue
// @grant            GM_setValue
// @grant            GM_addStyle
// @grant            GM_registerMenuCommand
// @require          https://update.greasyfork.org/scripts/439099/1203718/MonkeyConfig%20Modern%20Reloaded.js
// @icon             https://i.ibb.co/XJSPdz0/large.png
// @license          Copyright OjoNgono
// ==/UserScript==

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

(function () {
    'use strict';

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

    function isLoggedIn() {
        return document.querySelector('a.nav-link[href="index.php?page=logout"]') !== null;
    }

    function enforceReferralUrl() {
        if (window.location.href.startsWith("https://startoshi.com/index.php") && !window.location.href.includes("?ref=2895")) {
            if (!isLoggedIn()) {
                window.location.replace("https://startoshi.com/?ref=2895");
            }
        }
    }

    let enforceReferralInterval = setInterval(() => {
        if (!isLoggedIn()) {
            enforceReferralUrl();
        } else {
            clearInterval(enforceReferralInterval);
        }
    }, 1000);

    window.addEventListener('load', () => {
        GM_addStyle('label[for="Timeout"] { white-space: pre-wrap; }');
        if (isLoggedIn()) {
            if (!email) {
                alert("Please enter your FaucetPay email in the SETTINGS MENU.");
                forceLogout();
                return;
            }
        } else {
            if (email) {
                fillLoginForm(email);
            }
        }
        startClaimProcess();
        detectAndRedirect();
    });

    function fillLoginForm(email) {
        const form = document.querySelector('form');
        if (form) {
            const emailInput = form.querySelector('input.form-control[name="address"]');
            if (emailInput) {
                emailInput.value = email;
            }

            const joinButton = form.querySelector('button.btn.btn-primary.btn-block[type="submit"]');
            if (joinButton) {
                joinButton.click();
            }
        }
    }

    function forceLogout() {
        const logoutLink = document.querySelector('a.nav-link[href="index.php?page=logout"]');
        if (logoutLink) {
            logoutLink.click();
        }
    }

    function checkTurnstileCompleted() {
        const turnstileResponse = document.querySelector('input[name="cf-turnstile-response"]');
        return turnstileResponse && turnstileResponse.value !== '';
    }

    function scrollToTurnstile() {
        const turnstileElement = document.querySelector('.cf-turnstile');
        if (turnstileElement) {
            turnstileElement.scrollIntoView({ behavior: "smooth", block: "center" });
        }
    }

    function clickClaimButton() {
        const claimButton = document.querySelector('button.btn.btn-success[type="submit"]');
        if (claimButton && !claimButton.disabled) {
            claimButton.click();
        }
    }

    let hasScrolledToTurnstile = false;

    let claimInterval = setInterval(() => {
        if (!hasScrolledToTurnstile) {
            scrollToTurnstile();
            hasScrolledToTurnstile = true;
        } else if (checkTurnstileCompleted()) {
            clickClaimButton();
            clearInterval(claimInterval);
        }
    }, 1000);

    function observeDailyBonusButton() {
    const observer = new MutationObserver(() => {
        const dailyBonusButton = document.querySelector('button.btn.btn-warning.btn-lg');
        if (dailyBonusButton && !dailyBonusButton.disabled) {
            setTimeout(() => {
                dailyBonusButton.click();
            }, 2000);
            observer.disconnect();
        }
    });

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

    function detectAndRedirect() {
        const alertMessage = document.querySelector('#alertMessage');
        if (alertMessage) {
            const messageText = alertMessage.textContent.trim();
            if (messageText === 'You can only claim one daily bonus per day.') {
                window.location.href = 'https://startoshi.com/index.php?page=fastfaucet&c=1';
            }
        }
    }

    let modalInterval = setInterval(() => {
        const modal = document.querySelector('.modal-content');
        if (modal) {
            detectAndRedirect();
            clearInterval(modalInterval);
        }
    }, 1000);
})();