Easy Input

一键粘贴文本到当前页面的输入框.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Easy Input
// @namespace    zarttic
// @description  一键粘贴文本到当前页面的输入框.
// @author       zarttic
// @match        *
// @grant        none
// @license      MIT
// @version      1.03
// ==/UserScript==

(function() {
  'use strict';

  // 添加样式
  const style = document.createElement('style');
  style.textContent = `
    body {
      font-family: Arial, sans-serif;
      padding: 10px;
      width: 300px;
    }

    .container {
      text-align: center;
    }

    textarea {
      width: 100%;
      height: 100px;
      margin-bottom: 10px;
    }

    button {
      width: 100%;
      padding: 10px;
      background-color: #0078d7;
      color: white;
      border: none;
      cursor: pointer;
    }

    button:hover {
      background-color: #005a9e;
    }
  `;
  document.head.appendChild(style);

  // 创建一个容器
  const container = document.createElement('div');
  container.className = 'container';

  // 创建标题
  const title = document.createElement('h1');
  title.innerText = '😎Easy Input✍️';
  container.appendChild(title);

  // 创建文本区域
  const textarea = document.createElement('textarea');
  textarea.id = 'textInput';
  textarea.placeholder = '✍️粘贴到这里~~';
  container.appendChild(textarea);

  // 创建按钮
  const button = document.createElement('button');
  button.id = 'pasteButton';
  button.innerText = '👉一键粘贴👈';
  container.appendChild(button);

  // 添加容器到页面
  document.body.appendChild(container);

  // 监听按钮点击事件
  button.addEventListener('click', async () => {
    const text = textarea.value;
    if (text) {
      simulateInput(text);
    }
  });

  // 模拟输入函数
  function simulateInput(text) {
    const inputField = document.activeElement;
    if (inputField && (inputField.tagName === 'INPUT' || inputField.tagName === 'TEXTAREA')) {
      inputField.value = text;
      const event = new Event('input', { bubbles: true });
      inputField.dispatchEvent(event);
    }
  }
})();