X-Pick Auto ROLL

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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));
    }
})();