bulk paste

Paste clipboard content into all input fields on a webpage with one click

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         bulk paste
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Paste clipboard content into all input fields on a webpage with one click
// @author       You
// @author       You
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==
(function() {
    'use strict';

    let isEnabled = true
    // Create a button to trigger the paste function
    const div = document.createElement('button');
    div.textContent = "Active";
    div.style.position = 'fixed';
    div.style.top = '10px';
    div.style.right = '10px';
    div.style.backgroundColor="black"
    div.style.color="white"
    div.style.padding="0.5rem"
    div.style.borderRadius="10px"
    div.style.zIndex = 1000;
    const ref = document.body.appendChild(div);

    ref.addEventListener("click",(e)=>{
        isEnabled = !isEnabled
        if(isEnabled) ref.textContent = "Active"
        else ref.textContent = "Inactive"
    })

    // Function to paste clipboard content into input
    async function pasteClipboard(event) {
        try {
            const clipboardText = await navigator.clipboard.readText();
            event.target.value = clipboardText;
        } catch (err) {
            console.error('Failed to read clipboard contents: ', err);
        }
    }

    // Add event listener to all input elements
    document.addEventListener('click', function(event) {
        if (event.target.tagName === 'INPUT' && event.target.type === 'text' && isEnabled) {
            pasteClipboard(event);
        }
    });

})();