EasyScreenOCR 增加從剪貼簿上傳的功能

允許從剪貼簿直接上傳圖片並自動處理

目前為 2023-04-20 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         EasyScreenOCR 增加從剪貼簿上傳的功能
// @version      1.1
// @description  允許從剪貼簿直接上傳圖片並自動處理
// @include      https://online.easyscreenocr.com/*
// @grant        none
// @author       ani20168
// @icon         https://online.easyscreenocr.com/favicon.ico
// @namespace https://greasyfork.org/users/1044014
// ==/UserScript==

(function() {
    'use strict';

    // Modify the text inside the dropzone box
    var dropzoneText = document.querySelector('#drpText');
    dropzoneText.children[0].textContent = "拖曳圖像、點擊上傳或直接從剪貼簿上傳";
    dropzoneText.children[1].textContent = "(.png and .jpg only)";

    // Define the dropzone element
    var dropzone = document.querySelector('#drp');

    // Add the paste event listener to the dropzone element
    dropzone.addEventListener('paste', function(event) {
        // Get the clipboard data as an image file
        var items = (event.clipboardData || event.originalEvent.clipboardData).items;
        for (var i = 0; i < items.length; i++) {
            if (items[i].type.indexOf("image") !== -1) {
                var blob = items[i].getAsFile();

                // Create a new file object from the clipboard image data
                var file = new File([blob], "pasted-image.png", {type: "image/png"});

                // Add the file to the Dropzone queue
                dropzone.dropzone.addFile(file);
            }
        }
    });
})();