Greasy Fork 还支持 简体中文。

Reliable Fast Simulated Typing on Paste

Intercept and replace paste behavior with fast simulated typing (works across most sites)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reliable Fast Simulated Typing on Paste
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Intercept and replace paste behavior with fast simulated typing (works across most sites)
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    const CHUNK_SIZE = 100;

    window.addEventListener('paste', function (e) {
        const target = e.target;

        // Check for editable targets
        const isTextInput = (
            target instanceof HTMLTextAreaElement ||
            (target instanceof HTMLInputElement && target.type === 'text') ||
            target.isContentEditable
        );

        if (!isTextInput) return;

        e.stopImmediatePropagation(); // prevent site handlers
        e.preventDefault(); // cancel native paste

        const text = e.clipboardData.getData('text');
        let index = 0;

        function insertChunk() {
            const chunk = text.slice(index, index + CHUNK_SIZE);

            if (target.isContentEditable) {
                const selection = window.getSelection();
                const range = selection.getRangeAt(0);
                range.deleteContents();
                range.insertNode(document.createTextNode(chunk));
                range.collapse(false);
                selection.removeAllRanges();
                selection.addRange(range);
            } else {
                const start = target.selectionStart;
                const end = target.selectionEnd;
                const before = target.value.slice(0, start);
                const after = target.value.slice(end);
                target.value = before + chunk + after;
                const cursorPos = start + chunk.length;
                target.setSelectionRange(cursorPos, cursorPos);
            }

            target.dispatchEvent(new Event('input', { bubbles: true }));
            index += CHUNK_SIZE;

            if (index < text.length) {
                requestAnimationFrame(insertChunk);
            }
        }

        target.focus();
        insertChunk();
    }, true); // <-- useCapture = true is critical
})();