Monkeytype Universal Stealth (Fix)

Bypasses hidden input blocks. Targeted at 145-150 WPM.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name         Monkeytype Universal Stealth (Fix)
// @namespace    http://tampermonkey.net/
// @version      5.0
// @description  Bypasses hidden input blocks. Targeted at 145-150 WPM.
// @author       You
// @match        *://monkeytype.com/*
// @match        *://themonkeytype.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let isTyping = false;
    let lastShiftTime = 0;

    // --- UI OVERLAY ---
    const ui = document.createElement('div');
    ui.id = "bot-ui-v5";
    ui.innerHTML = `
        <div style="position: fixed; bottom: 20px; left: 20px; z-index: 10000; background: #1e1e20; color: #e2b714; padding: 15px; border-radius: 10px; font-family: 'Courier New', monospace; border: 2px solid #e2b714; width: 230px; box-shadow: 0 0 30px rgba(0,0,0,0.7);">
            <div style="font-weight:bold; font-size:14px; margin-bottom:10px; text-align:center;">STEALTH V5.0</div>
            WPM: <input type="number" id="wpm-val" value="152" style="width:50px; float:right; background:#2c2e31; color:#e2b714; border:1px solid #444; border-radius:3px;"><br><br>
            ACC: <input type="number" id="acc-val" value="98" style="width:50px; float:right; background:#2c2e31; color:#e2b714; border:1px solid #444; border-radius:3px;"><br><br>
            <button id="toggle-btn" style="width:100%; padding:10px; background:#e2b714; color:#1e1e20; border:none; cursor:pointer; font-weight:bold; border-radius:5px; text-transform:uppercase;">Start (Double Shift)</button>
            <div id="status-display" style="margin-top:10px; color:#646669; font-size:10px; text-align:center;">Mode: Hidden Input Target</div>
        </div>
    `;
    document.body.appendChild(ui);

    // --- HELPERS ---
    const sleep = (ms) => new Promise(r => setTimeout(r, ms));
    const getRandom = (min, max) => Math.random() * (max - min) + min;

    // SCRAPER: Targets <letter> tags specifically for monkeytype.com
    const getWords = () => {
        let text = "";
        const wordElements = document.querySelectorAll('#words .word');

        if (wordElements.length > 0) {
            wordElements.forEach((word, i) => {
                const letters = word.querySelectorAll('letter');
                letters.forEach(l => text += l.textContent);
                if (i < wordElements.length - 1) text += " ";
            });
        } else {
            // Fallback for themonkeytype.com
            const spans = document.querySelectorAll('.words span, div[style*="transform"] span');
            spans.forEach(span => {
                if (span.classList.contains('text-white/50') || span.textContent === '\u00A0' || span.innerHTML === '&nbsp;') {
                    text += " ";
                } else if (span.textContent.length === 1) {
                    text += span.textContent;
                }
            });
        }
        return text.trim();
    };

    // ENGINE: The most reliable way to simulate typing on Monkeytype
    const typeChar = (char) => {
        // Look for the hidden input fields used by various versions
        const input = document.getElementById('wordsInput') ||
                      document.querySelector('.wordsInput') ||
                      document.getElementById('typingTestInput') ||
                      document.querySelector('input.absolute');

        if (!input) return false;

        // Force focus so the site listens
        input.focus();

        const keyCode = char === 'Backspace' ? 8 : char.charCodeAt(0);
        const eventObj = { key: char, keyCode: keyCode, which: keyCode, bubbles: true, cancelable: true };

        // 1. Keydown
        input.dispatchEvent(new KeyboardEvent('keydown', eventObj));

        // 2. Update Value (Required for modern Monkeytype detection bypass)
        if (char === 'Backspace') {
            input.value = input.value.slice(0, -1);
        } else {
            input.value += char;
        }

        // 3. Input Event
        input.dispatchEvent(new InputEvent('input', { data: char, inputType: char === 'Backspace' ? 'deleteContentBackward' : 'insertText', bubbles: true }));

        // 4. Keyup
        input.dispatchEvent(new KeyboardEvent('keyup', eventObj));

        return true;
    };

    async function startTyping() {
        if (isTyping) { isTyping = false; return; }

        const text = getWords();
        if (!text) {
            console.error("Text not found. Ensure the test has started.");
            return;
        }

        const targetWpm = parseInt(document.getElementById('wpm-val').value);
        const targetAcc = parseInt(document.getElementById('acc-val').value) / 100;

        // Math: 152 WPM target to hit ~148 WPM actual results
        let baseDelay = 60000 / (targetWpm * 5);

        isTyping = true;
        document.getElementById('toggle-btn').innerText = "Stop";
        document.getElementById('toggle-btn').style.background = "#ca4754";

        for (let i = 0; i < text.length; i++) {
            if (!isTyping) break;

            const char = text[i];

            // --- COMPLEX MISTAKE ENGINE ---
            if (Math.random() > targetAcc && char !== ' ' && i < text.length - 5) {
                const wrong = "abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random() * 26)];
                typeChar(wrong);
                await sleep(getRandom(80, 140)); // Realization delay
                typeChar('Backspace');
                await sleep(getRandom(40, 60));
            }

            // --- SPEED CALIBRATION (76% Consistency) ---
            // We use Gaussian Jitter to prevent robotic timing
            let jitter = (Math.random() + Math.random() + Math.random() - 1.5) * 20;
            let delay = baseDelay + jitter;

            // Ramping (Start slower)
            if (i < (text.length * 0.1)) delay += 10;

            // Common Digraph Bursting (the, er, on)
            if ("theandinersereon".includes(text.substring(i-1, i+1))) delay *= 0.85;

            // Spacebar Pause (Natural thumb delay)
            if (char === ' ') delay += getRandom(15, 35);

            const success = typeChar(char);
            if (!success) {
                isTyping = false;
                alert("Input field not found. Click the words and try again.");
                break;
            }

            await sleep(delay);
        }

        isTyping = false;
        document.getElementById('toggle-btn').innerText = "Start (Double Shift)";
        document.getElementById('toggle-btn').style.background = "#e2b714";
    }

    // --- DOUBLE SHIFT TRIGGER ---
    window.addEventListener('keydown', (e) => {
        if (e.key === 'Shift') {
            const now = Date.now();
            if (now - lastShiftTime < 300) {
                startTyping();
                lastShiftTime = 0;
            } else {
                lastShiftTime = now;
            }
        }
    });

    document.getElementById('toggle-btn').onclick = startTyping;
})();