Human-Typer by Warrior

Simulate human typing in Google Docs and Slides with customizable settings such as typing speed, errors, and breaks.

目前为 2024-04-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         Human-Typer by Warrior
// @description  Simulate human typing in Google Docs and Slides with customizable settings such as typing speed, errors, and breaks.
// @version      1.1
// @namespace    http://yournamespace.com/human-typer
// @match        *://docs.google.com/document/*
// @match        *://docs.google.com/presentation/*
// @include      *://docs.google.com/document/*
// @include      *://docs.google.com/presentation/*
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Constants for typing speeds
    const typingSpeeds = {
        fast: { lower: 50, upper: 150 },
        medium: { lower: 60, upper: 220 },
        normal: { lower: 70, upper: 200 },
        slow: { lower: 80, upper: 240 }
    };

    // Variables
    let typingInProgress = false;
    let cancelTyping = false;

    // Create the "Human Typer" button
    const createHumanTyperButton = () => {
        const button = document.createElement('button');
        button.textContent = 'Human Typer';
        button.style.position = 'fixed';
        button.style.bottom = '10px';
        button.style.right = '10px';
        button.style.backgroundColor = 'black';
        button.style.color = 'white';
        button.style.padding = '10px';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.cursor = 'pointer';
        button.addEventListener('click', showOverlay);
        document.body.appendChild(button);
    };

    // Function to display the overlay for user input
    const showOverlay = () => {
        // Create overlay elements
        const overlay = document.createElement('div');
        overlay.style.position = 'fixed';
        overlay.style.bottom = '10px';
        overlay.style.right = '10px';
        overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        overlay.style.padding = '10px';
        overlay.style.borderRadius = '5px';
        overlay.style.zIndex = '9999';
        
        const textarea = document.createElement('textarea');
        textarea.placeholder = 'Enter your text...';
        textarea.style.width = '200px';
        textarea.style.height = '100px';
        textarea.style.marginBottom = '10px';

        const speedSelect = document.createElement('select');
        for (const speed in typingSpeeds) {
            const option = document.createElement('option');
            option.value = speed;
            option.textContent = speed.charAt(0).toUpperCase() + speed.slice(1);
            speedSelect.appendChild(option);
        }

        const startButton = document.createElement('button');
        startButton.textContent = 'Start';
        startButton.addEventListener('click', () => {
            const speed = speedSelect.value;
            const userText = textarea.value.trim();
            overlay.remove();
            startTyping(userText, speed);
        });

        // Append elements to overlay
        overlay.appendChild(textarea);
        overlay.appendChild(speedSelect);
        overlay.appendChild(startButton);
        document.body.appendChild(overlay);
    };

    // Function to start typing with the selected speed
    const startTyping = (text, speed) => {
        if (typingInProgress) return;

        const speedValues = typingSpeeds[speed] || typingSpeeds.normal;
        const iframe = document.querySelector('.docs-texteventtarget-iframe');
        const activeElement = iframe.contentDocument.activeElement;

        typingInProgress = true;

        // Simulate typing
        (async () => {
            for (let i = 0; i < text.length; i++) {
                if (cancelTyping) break;

                activeElement.value += text[i];
                await new Promise(resolve => setTimeout(resolve, Math.random() * (speedValues.upper - speedValues.lower) + speedValues.lower));

                // Simulate mistakes
                if (Math.random() < 0.05) {
                    activeElement.value += text[i]; // Add a mistake
                    await new Promise(resolve => setTimeout(resolve, Math.random() * (speedValues.upper - speedValues.lower) + speedValues.lower));
                    activeElement.value = activeElement.value.slice(0, -1); // Correct the mistake
                }
            }

            typingInProgress = false;
        })();
    };

    // Initialize the Human Typer button
    createHumanTyperButton();

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址