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

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

目前为 2023-04-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name EasyScreenOCR 增加從剪貼簿上傳的功能
  3. // @version 1.1
  4. // @description 允許從剪貼簿直接上傳圖片並自動處理
  5. // @include https://online.easyscreenocr.com/*
  6. // @grant none
  7. // @author ani20168
  8. // @icon https://online.easyscreenocr.com/favicon.ico
  9. // @namespace https://greasyfork.org/users/1044014
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Modify the text inside the dropzone box
  16. var dropzoneText = document.querySelector('#drpText');
  17. dropzoneText.children[0].textContent = "拖曳圖像、點擊上傳或直接從剪貼簿上傳";
  18. dropzoneText.children[1].textContent = "(.png and .jpg only)";
  19.  
  20. // Define the dropzone element
  21. var dropzone = document.querySelector('#drp');
  22.  
  23. // Add the paste event listener to the dropzone element
  24. dropzone.addEventListener('paste', function(event) {
  25. // Get the clipboard data as an image file
  26. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  27. for (var i = 0; i < items.length; i++) {
  28. if (items[i].type.indexOf("image") !== -1) {
  29. var blob = items[i].getAsFile();
  30.  
  31. // Create a new file object from the clipboard image data
  32. var file = new File([blob], "pasted-image.png", {type: "image/png"});
  33.  
  34. // Add the file to the Dropzone queue
  35. dropzone.dropzone.addFile(file);
  36. }
  37. }
  38. });
  39. })();
  40.  
  41.  
  42.  
  43.  
  44.  
  45.