| (function () {
|
| console.log("%c Monkeytype Command Typer (Human-Like) ", "background: #222; color: #ff0000; font-size: 20px");
|
|
|
| const CONFIG = {
|
| minWPM: 310,
|
| maxWPM: 550,
|
| startDelay: 50,
|
|
|
|
|
|
|
| wrongCharRate: 0.025,
|
|
|
|
|
| adjacentKeyRate: 0.02,
|
|
|
|
|
| doubleLetterRate: 0.015,
|
| tripleLetterRate: 0.003,
|
|
|
|
|
| skipLetterRate: 0.01,
|
|
|
|
|
| transposeRate: 0.012,
|
|
|
|
|
| ctrlBackspaceRate: 0.008,
|
|
|
|
|
| hesitationRate: 0.04,
|
| hesitationMultiplier: 3.5,
|
|
|
|
|
| burstTypingRate: 0.08,
|
| burstSpeedMultiplier: 0.5,
|
| burstLength: 5,
|
|
|
|
|
| wordStartSlowdown: 1.8,
|
|
|
|
|
| fatigueEnabled: true,
|
| fatigueRate: 0.0001,
|
|
|
|
|
| postMistakePauseMultiplier: 2.0,
|
| };
|
|
|
|
|
| const ADJACENT_KEYS = {
|
| 'a': ['q', 'w', 's', 'z'],
|
| 'b': ['v', 'g', 'h', 'n'],
|
| 'c': ['x', 'd', 'f', 'v'],
|
| 'd': ['s', 'e', 'r', 'f', 'c', 'x'],
|
| 'e': ['w', 's', 'd', 'r'],
|
| 'f': ['d', 'r', 't', 'g', 'v', 'c'],
|
| 'g': ['f', 't', 'y', 'h', 'b', 'v'],
|
| 'h': ['g', 'y', 'u', 'j', 'n', 'b'],
|
| 'i': ['u', 'j', 'k', 'o'],
|
| 'j': ['h', 'u', 'i', 'k', 'm', 'n'],
|
| 'k': ['j', 'i', 'o', 'l', 'm'],
|
| 'l': ['k', 'o', 'p'],
|
| 'm': ['n', 'j', 'k'],
|
| 'n': ['b', 'h', 'j', 'm'],
|
| 'o': ['i', 'k', 'l', 'p'],
|
| 'p': ['o', 'l'],
|
| 'q': ['w', 'a'],
|
| 'r': ['e', 'd', 'f', 't'],
|
| 's': ['a', 'w', 'e', 'd', 'x', 'z'],
|
| 't': ['r', 'f', 'g', 'y'],
|
| 'u': ['y', 'h', 'j', 'i'],
|
| 'v': ['c', 'f', 'g', 'b'],
|
| 'w': ['q', 'a', 's', 'e'],
|
| 'x': ['z', 's', 'd', 'c'],
|
| 'y': ['t', 'g', 'h', 'u'],
|
| 'z': ['a', 's', 'x'],
|
| };
|
|
|
| let isArmed = true;
|
| let inBurstMode = false;
|
| let burstCharsRemaining = 0;
|
| let totalCharsTyped = 0;
|
| let recentMistake = false;
|
|
|
|
|
| function typeChar(char) {
|
| const target = document.activeElement || document.body;
|
| const keyConfig = {
|
| key: char,
|
| code: char === ' ' ? 'Space' : `Key${char.toUpperCase()}`,
|
| bubbles: true,
|
| cancelable: true,
|
| view: window
|
| };
|
|
|
| target.dispatchEvent(new KeyboardEvent('keydown', keyConfig));
|
| target.dispatchEvent(new KeyboardEvent('keypress', keyConfig));
|
| document.execCommand('insertText', false, char);
|
| target.dispatchEvent(new KeyboardEvent('keyup', keyConfig));
|
|
|
| totalCharsTyped++;
|
| }
|
|
|
|
|
| function typeBackspace() {
|
| const target = document.activeElement || document.body;
|
| const bsConfig = { key: 'Backspace', code: 'Backspace', bubbles: true, cancelable: true, view: window };
|
| target.dispatchEvent(new KeyboardEvent('keydown', bsConfig));
|
| document.execCommand('delete', false, null);
|
| target.dispatchEvent(new KeyboardEvent('keyup', bsConfig));
|
| }
|
|
|
|
|
| function typeCtrlBackspace() {
|
| const target = document.activeElement || document.body;
|
| const ctrlBsConfig = {
|
| key: 'Backspace',
|
| code: 'Backspace',
|
| ctrlKey: true,
|
| bubbles: true,
|
| cancelable: true,
|
| view: window
|
| };
|
|
|
| target.dispatchEvent(new KeyboardEvent('keydown', ctrlBsConfig));
|
|
|
|
|
| const activeWord = document.querySelector('#words .word.active');
|
| if (activeWord) {
|
| const incorrectLetters = activeWord.querySelectorAll('letter.incorrect, letter.extra');
|
| incorrectLetters.forEach(() => {
|
| document.execCommand('delete', false, null);
|
| });
|
| }
|
|
|
| target.dispatchEvent(new KeyboardEvent('keyup', ctrlBsConfig));
|
| }
|
|
|
| function sleep(ms) {
|
| return new Promise(resolve => setTimeout(resolve, ms));
|
| }
|
|
|
|
|
| function getAdjacentKey(char) {
|
| const lowerChar = char.toLowerCase();
|
| const adjacent = ADJACENT_KEYS[lowerChar];
|
| if (adjacent && adjacent.length > 0) {
|
| const randomAdj = adjacent[Math.floor(Math.random() * adjacent.length)];
|
| return char === char.toUpperCase() ? randomAdj.toUpperCase() : randomAdj;
|
| }
|
| return char;
|
| }
|
|
|
|
|
| function getRandomChar() {
|
| const chars = "abcdefghijklmnopqrstuvwxyz";
|
| return chars.charAt(Math.floor(Math.random() * chars.length));
|
| }
|
|
|
|
|
| function getKeystrokeDelay() {
|
| const currentWPM = Math.floor(Math.random() * (CONFIG.maxWPM - CONFIG.minWPM + 1)) + CONFIG.minWPM;
|
| let baseDelay = 60000 / (currentWPM * 5);
|
|
|
|
|
| if (CONFIG.fatigueEnabled) {
|
| baseDelay *= (1 + totalCharsTyped * CONFIG.fatigueRate);
|
| }
|
|
|
|
|
| if (inBurstMode && burstCharsRemaining > 0) {
|
| baseDelay *= CONFIG.burstSpeedMultiplier;
|
| burstCharsRemaining--;
|
| if (burstCharsRemaining === 0) {
|
| inBurstMode = false;
|
| }
|
| }
|
|
|
|
|
| const variance = baseDelay * 0.25;
|
| const noise = (Math.random() * variance * 2) - variance;
|
|
|
| return Math.max(8, baseDelay + noise);
|
| }
|
|
|
|
|
| function getCurrentWordText() {
|
| const activeWord = document.querySelector('#words .word.active');
|
| if (!activeWord) return null;
|
|
|
| const letters = activeWord.querySelectorAll('letter');
|
| let text = "";
|
| let foundUntyped = false;
|
|
|
| for (const letter of letters) {
|
| if (!letter.classList.contains('correct') && !letter.classList.contains('incorrect')) {
|
| foundUntyped = true;
|
| }
|
| if (foundUntyped) {
|
| text += letter.textContent;
|
| }
|
| }
|
|
|
| return text;
|
| }
|
|
|
|
|
| function getIncorrectCount() {
|
| const activeWord = document.querySelector('#words .word.active');
|
| if (!activeWord) return 0;
|
| return activeWord.querySelectorAll('letter.incorrect, letter.extra').length;
|
| }
|
|
|
|
|
| function isWordStart() {
|
| const activeWord = document.querySelector('#words .word.active');
|
| if (!activeWord) return false;
|
| const typed = activeWord.querySelectorAll('letter.correct, letter.incorrect');
|
| return typed.length === 0;
|
| }
|
|
|
|
|
|
|
|
|
| async function simulateWrongChar(correctChar) {
|
| const wrongChar = getRandomChar();
|
| typeChar(wrongChar);
|
| await sleep(getKeystrokeDelay() * 2.5);
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 1.5);
|
| recentMistake = true;
|
| }
|
|
|
|
|
| async function simulateAdjacentKeyTypo(correctChar) {
|
| const adjacentChar = getAdjacentKey(correctChar);
|
| if (adjacentChar !== correctChar) {
|
| typeChar(adjacentChar);
|
| await sleep(getKeystrokeDelay() * 2.2);
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 1.3);
|
| recentMistake = true;
|
| }
|
| }
|
|
|
|
|
| async function simulateDoubleLetter(char, count = 2) {
|
|
|
| for (let i = 1; i < count; i++) {
|
| typeChar(char);
|
| await sleep(getKeystrokeDelay() * 0.3);
|
| }
|
|
|
| await sleep(getKeystrokeDelay() * 2.0);
|
|
|
| for (let i = 1; i < count; i++) {
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 0.5);
|
| }
|
| await sleep(getKeystrokeDelay() * 1.2);
|
| recentMistake = true;
|
| }
|
|
|
|
|
| async function simulateSkipLetter() {
|
|
|
|
|
|
|
| return true;
|
| }
|
|
|
|
|
| async function simulateTranspose(char1, char2) {
|
|
|
| typeChar(char2);
|
| await sleep(getKeystrokeDelay() * 0.4);
|
|
|
| typeChar(char1);
|
| await sleep(getKeystrokeDelay() * 2.5);
|
|
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 0.4);
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 1.5);
|
| recentMistake = true;
|
|
|
| return true;
|
| }
|
|
|
|
|
| async function simulateCtrlBackspace() {
|
| const incorrectCount = getIncorrectCount();
|
| if (incorrectCount > 2) {
|
| await sleep(getKeystrokeDelay() * 3);
|
| typeCtrlBackspace();
|
| await sleep(getKeystrokeDelay() * 2);
|
| recentMistake = true;
|
| return true;
|
| }
|
| return false;
|
| }
|
|
|
|
|
| async function autoTypeLoop() {
|
| console.log("Starting human-like auto-type loop...");
|
| console.log("Active imperfections: wrong char, adjacent key, double/triple letter, skip, transpose, Ctrl+Backspace, hesitation, burst typing, fatigue");
|
|
|
| let wordCount = 0;
|
| let skipNext = false;
|
|
|
| while (true) {
|
| const currentWordText = getCurrentWordText();
|
|
|
| if (currentWordText === null) {
|
| console.log(`Auto-type complete! Typed ${wordCount} words, ${totalCharsTyped} characters.`);
|
| break;
|
| }
|
|
|
|
|
| if (Math.random() < CONFIG.ctrlBackspaceRate) {
|
| const didCtrlBackspace = await simulateCtrlBackspace();
|
| if (didCtrlBackspace) continue;
|
| }
|
|
|
| if (currentWordText.length === 0) {
|
| const activeWord = document.querySelector('#words .word.active');
|
| const nextWord = activeWord ? activeWord.nextElementSibling : null;
|
|
|
| if (!nextWord || !nextWord.classList.contains('word')) {
|
| await sleep(50);
|
| const stillActive = document.querySelector('#words .word.active');
|
| if (!stillActive) {
|
| console.log(`Auto-type complete! Typed ${wordCount} words.`);
|
| break;
|
| }
|
| continue;
|
| }
|
|
|
| typeChar(' ');
|
| wordCount++;
|
|
|
|
|
| let delay = getKeystrokeDelay() * 1.4;
|
| await sleep(delay);
|
| continue;
|
| }
|
|
|
| const char = currentWordText[0];
|
| const nextChar = currentWordText.length > 1 ? currentWordText[1] : null;
|
| let delay = getKeystrokeDelay();
|
|
|
|
|
|
|
|
|
| if (isWordStart()) {
|
| delay *= CONFIG.wordStartSlowdown;
|
| }
|
|
|
|
|
| if (Math.random() < CONFIG.hesitationRate) {
|
| delay *= CONFIG.hesitationMultiplier;
|
| }
|
|
|
|
|
| if (recentMistake) {
|
| delay *= CONFIG.postMistakePauseMultiplier;
|
| recentMistake = false;
|
| }
|
|
|
|
|
| if (!inBurstMode && Math.random() < CONFIG.burstTypingRate) {
|
| inBurstMode = true;
|
| burstCharsRemaining = CONFIG.burstLength;
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && Math.random() < CONFIG.skipLetterRate && nextChar) {
|
|
|
| typeChar(nextChar);
|
| await sleep(getKeystrokeDelay() * 2.5);
|
| typeBackspace();
|
| await sleep(getKeystrokeDelay() * 1.3);
|
| recentMistake = true;
|
|
|
| typeChar(char);
|
| await sleep(delay);
|
| continue;
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && nextChar && /[a-zA-Z]/.test(nextChar) && Math.random() < CONFIG.transposeRate) {
|
| await simulateTranspose(char, nextChar);
|
|
|
| typeChar(char);
|
| await sleep(getKeystrokeDelay());
|
| typeChar(nextChar);
|
| await sleep(delay);
|
|
|
| skipNext = true;
|
| continue;
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && Math.random() < CONFIG.tripleLetterRate) {
|
| typeChar(char);
|
| await simulateDoubleLetter(char, 3);
|
| await sleep(delay);
|
| continue;
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && Math.random() < CONFIG.doubleLetterRate) {
|
| typeChar(char);
|
| await simulateDoubleLetter(char, 2);
|
| await sleep(delay);
|
| continue;
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && Math.random() < CONFIG.adjacentKeyRate) {
|
| await simulateAdjacentKeyTypo(char);
|
| }
|
|
|
|
|
| if (/[a-zA-Z]/.test(char) && Math.random() < CONFIG.wrongCharRate) {
|
| await simulateWrongChar(char);
|
| }
|
|
|
|
|
| typeChar(char);
|
| await sleep(delay);
|
| }
|
| }
|
|
|
| const triggerHandler = (e) => {
|
| if (!isArmed) return;
|
|
|
| if (e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
| const activeWord = document.querySelector('#words .word.active');
|
| if (!activeWord) return;
|
|
|
| const firstLetterElement = activeWord.querySelector('letter');
|
| const firstLetter = firstLetterElement ? firstLetterElement.textContent : null;
|
|
|
| if (firstLetter && e.key === firstLetter) {
|
| isArmed = false;
|
| window.removeEventListener('keydown', triggerHandler);
|
|
|
| console.log("Trigger detected. Starting Human-Like Command Typer...");
|
| console.log("Config:", CONFIG);
|
| setTimeout(() => {
|
| autoTypeLoop();
|
| }, CONFIG.startDelay);
|
| }
|
| }
|
| };
|
|
|
| window.addEventListener('keydown', triggerHandler);
|
| console.log("READY! Type the first letter to activate Human-Like Mode.");
|
| console.log("Imperfections enabled: wrong char, adjacent key typo, double/triple letter, skip, transpose, Ctrl+Backspace, hesitation, burst typing, fatigue, word-start slowdown");
|
| })();
|
|
|