Turbo.cr Auto-Captcha Solver

Robust, CPU-efficient, and bot-safe Altcha solver for turbo.cr

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

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

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

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

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

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

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

Advertisement:

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

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

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

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

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

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

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

Advertisement:

// ==UserScript==
// @name         Turbo.cr Auto-Captcha Solver
// @namespace    http://tampermonkey.net/
// @icon data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB4PSIyIiB5PSIyIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHJ4PSIxMiIgZmlsbD0iYmxhY2siIGZpbGwtb3BhY2l0eT0iMC4wNSIgZmlsdGVyPSJibHVyKDNweCkiLz48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImciIHgxPSIwIiB5MT0iMzYiIHgyPSIzNiIgeTI9IjAiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjRjQzRjVFIi8+PHN0b3Agb2Zmc2V0PSI1MCUiIHN0b3AtY29sb3I9IiNFRjQ0NDQiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNGQkJGMjQiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHJ4PSIxMiIgZmlsbD0idXJsKCNnKSIvPjwvc3ZnPg==
// @version      2.0
// @description  Robust, CPU-efficient, and bot-safe Altcha solver for turbo.cr
// @author       lol_nocode
// @match        https://turbo.cr/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Configuration
    const CONFIG = {
        debounceMs: 50,           // Wait 50ms after DOM changes settle before checking
        lockoutMs: 3000,          // Wait 3 seconds before allowing a retry on the same captcha
        lockAttr: 'data-gm-lock'  // Custom attribute to prevent duplicate clicks
    };

    /**
     * Safely triggers the captcha by simulating a human interacting with the label.
     * @param {HTMLElement} container - The main altcha container
     * @param {HTMLElement} checkbox - The hidden or styled input element
     */
    function interactWithCaptcha(container, checkbox) {
        // Find the label associated with the checkbox (most framework-safe way to click)
        const label = container.querySelector(`label[for="${checkbox.id}"]`);
        const targetElement = label || checkbox;

        // Apply a temporary lock to prevent spam-clicking while Altcha processes
        checkbox.setAttribute(CONFIG.lockAttr, 'true');

        console.log('[Auto-Captcha] Solving Altcha...');

        // 1. Focus the element natively
        targetElement.focus();

        // 2. Dispatch a native-like click sequence
        ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click'].forEach(eventType => {
            targetElement.dispatchEvent(new MouseEvent(eventType, {
                view: window,
                bubbles: true,
                cancelable: true,
                buttons: 1
            }));
        });

        // 3. Fallback: Ensure the state changes if the native click failed
        if (!checkbox.checked) {
            checkbox.checked = true;
            checkbox.dispatchEvent(new Event('input', { bubbles: true }));
            checkbox.dispatchEvent(new Event('change', { bubbles: true }));
        }

        // Release the lock after a few seconds in case the captcha failed and reset
        setTimeout(() => {
            if (checkbox.hasAttribute(CONFIG.lockAttr)) {
                checkbox.removeAttribute(CONFIG.lockAttr);
            }
        }, CONFIG.lockoutMs);
    }

    /**
     * Scans the DOM for unverified, unlocked captchas.
     */
    function scanAndSolve() {
        try {
            const containers = document.querySelectorAll('.altcha[data-state="unverified"]');

            containers.forEach(container => {
                const checkbox = container.querySelector('.altcha-checkbox input[type="checkbox"]');

                // Only interact if we found the checkbox and it isn't currently locked by our script
                if (checkbox && !checkbox.hasAttribute(CONFIG.lockAttr)) {
                    interactWithCaptcha(container, checkbox);
                }
            });
        } catch (error) {
            console.error('[Auto-Captcha] Error during scan:', error);
        }
    }

    // --- Debounced Mutation Observer ---
    let debounceTimer;

    const observer = new MutationObserver(() => {
        clearTimeout(debounceTimer);
        debounceTimer = setTimeout(scanAndSolve, CONFIG.debounceMs);
    });

    // Start observing as soon as the body or documentElement is available
    const targetNode = document.body || document.documentElement;
    if (targetNode) {
        observer.observe(targetNode, {
            childList: true,
            subtree: true,
            attributes: true,
            attributeFilter: ['data-state'] // Only trigger on relevant state changes
        });
    }

    // Initial check on load
    scanAndSolve();

})();