X-Pick Auto ROLL

Automatically switches captcha type to Turnstile and clicks "ROLL" when solved, for *pick faucets

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         X-Pick Auto ROLL
// @version      1.2
// @description  Automatically switches captcha type to Turnstile and clicks "ROLL" when solved, for *pick faucets
// @author       Coraxdevil
// @match        *://litepick.io/faucet.php
// @match        *://tronpick.io/faucet.php
// @match        *://dogepick.io/faucet.php
// @match        *://solpick.io/faucet.php
// @match        *://bnbpick.io/faucet.php
// @match        *://bchpick.io/faucet.php
// @match        *://tonpick.game/faucet.php
// @match        *://suipick.io/faucet.php
// @match        *://polpick.io/faucet.php
// @license      MIT
// @grant        none
// @namespace https://greasyfork.org/users/1630541
// ==/UserScript==

(function () {
    'use strict';

    const log = (...args) => console.log('[AutoROLL]', ...args);

    // === Options ===
    const POLL_INTERVAL       = 2000;   
    const SWITCH_INTERVAL     = 3000;   
    const SWITCH_MAX_ATTEMPTS = 20;     
    const RELOAD_AFTER_CLICK  = 15000;  
    const FALLBACK_RELOAD     = 5 * 60 * 1000;

    let switched        = false;
    let clicked         = false;
    let switchAttempts = 0;
    let lastSwitchAt    = 0;
    let switchPending   = false; 
    
    function isCaptchaResolved() {
        const input = document.querySelector('input[name="cf-turnstile-response"]');
        return !!(input && input.value && input.value.trim().length > 0);
    }

    function isTurnstileActive() {

        return !!document.querySelector('input[name="cf-turnstile-response"]')
            || !!document.querySelector('iframe[src*="challenges.cloudflare.com"]');
    }

    function tryChangeCaptchaType() {
        if (switched) return true;
        if (switchPending) return false; 

        if (isTurnstileActive()) {
            log("Turnstile is already active.");
            switched = true;
            return true;
        }

        if (switchAttempts >= SWITCH_MAX_ATTEMPTS) {
            log("Max switch attempts reached. Reloading page.");
            location.reload();
            return false;
        }
        switchAttempts++;
        log(`Switch attempt ${switchAttempts}/${SWITCH_MAX_ATTEMPTS}`);

        // --- Метод 1: нативный <select> ---
        const select = document.querySelector('#select_captcha');
        if (select && select.tagName === 'SELECT') {

            const turnstileOpt = Array.from(select.options).find(opt =>
                /turnstile/i.test(opt.text) || /turnstile/i.test(opt.value)
            );
            const targetOpt = turnstileOpt
                || (select.options.length >= 2 ? select.options[1] : null);

            if (targetOpt && select.value !== targetOpt.value) {
                log(`Setting <select> to "${targetOpt.text || targetOpt.value}".`);
                select.value = targetOpt.value;
                select.dispatchEvent(new Event('change', { bubbles: true }));
                return false;
            }
            if (targetOpt && select.value === targetOpt.value) {
               
                return false;
            }
        }


        const wrapper = document.querySelector("#faucet_claim > div.form__input-wrapper > div");
        if (wrapper) {
            log("Opening custom captcha dropdown.");
            wrapper.click();
            switchPending = true;

            setTimeout(() => {
                switchPending = false;
                const option =
                    document.querySelector("#select_captcha > option:nth-child(2)") ||
                    document.querySelector("#select_captcha > li:nth-child(2)") ||
                    document.querySelector("#select_captcha > div:nth-child(2)") ||
                    document.querySelector("#select_captcha > *:nth-child(2)");
                if (option) {
                    log("Clicking second option (assumed Turnstile).");
                    option.click();

                    if (select && select.tagName === 'SELECT') {
                        select.dispatchEvent(new Event('change', { bubbles: true }));
                    }
                } else {
                    log("Second option not found in dropdown.");
                }
            }, 400);
            return false;
        }

        log("Captcha selector not found.");
        return false;
    }

    function tryClickRollButton() {
        if (clicked) return true;
        const button = document.querySelector("#process_claim_hourly_faucet");
        if (!button) {
            log("ROLL! button not found.");
            return false;
        }
        if (isCaptchaResolved() && !button.disabled && button.offsetParent !== null) {
            log("CAPTCHA solved. Clicking ROLL!");
            button.click();
            clicked = true;
            return true;
        }

        return false;
    }

    function poll() {
        if (clicked) return;

        const now = Date.now();
        if (!switched && !switchPending && now - lastSwitchAt >= SWITCH_INTERVAL) {
            lastSwitchAt = now;
            tryChangeCaptchaType();
        }

        if (tryClickRollButton()) {
            setTimeout(() => location.reload(), RELOAD_AFTER_CLICK);
        }
    }

    function start() {
        log("Starting AutoROLL watcher.");

        lastSwitchAt = Date.now();
        tryChangeCaptchaType();

        setInterval(poll, POLL_INTERVAL);

        setTimeout(() => {
            if (!clicked) {
                log("Fallback reload — no claim detected in time window.");
                location.reload();
            }
        }, FALLBACK_RELOAD);
    }

    if (document.readyState === 'complete' || document.readyState === 'interactive') {
        setTimeout(start, 1500);
    } else {
        window.addEventListener('DOMContentLoaded', () => setTimeout(start, 1500));
    }
})();