10FastFingers correcter

Each key types the correct letter.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         10FastFingers correcter
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  Each key types the correct letter.
// @author       Kakoncheater
// @match        https://10ff.net/*
// @match        https://10fastfingers.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function findInput() {
        return document.querySelector('#word-input') ||
               document.querySelector('input[type="text"]') ||
               document.querySelector('input');
    }

    document.addEventListener('keydown', function(e) {
        const inputField = findInput();

        if (!inputField || document.activeElement !== inputField) return;

        if (e.key === 'Backspace' || e.key === 'Control' || e.key === 'Alt' ||
            e.key === 'Shift' || e.key === 'Tab' || e.key === 'Enter') {
            return;
        }

        const highlight = document.querySelector('.highlight');

        if (highlight) {
            e.preventDefault();

            const targetWord = highlight.textContent;
            const currentVal = inputField.value;

            if (currentVal === targetWord) {
                inputField.value += " ";
                const eventInput = new Event('input', { bubbles: true });
                inputField.dispatchEvent(eventInput);

                const eventDown = new KeyboardEvent('keydown', {'key':' ', 'code':'Space', 'keyCode':32, 'which':32, 'bubbles':true});
                inputField.dispatchEvent(eventDown);

                const eventUp = new KeyboardEvent('keyup', {'key':' ', 'code':'Space', 'keyCode':32, 'which':32, 'bubbles':true});
                inputField.dispatchEvent(eventUp);
            }
            else if (currentVal.length < targetWord.length) {
                inputField.value += targetWord[currentVal.length];
                const event = new Event('input', { bubbles: true });
                inputField.dispatchEvent(event);
            }
        }
    });

})();