Greasy Fork is available in English.
在 iqdb 中使用 Ctrl + V 上传图片
当前为
// ==UserScript==
// @name iqdb Ctrl+V
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description 在 iqdb 中使用 Ctrl + V 上传图片
// @author apkipa
// @match https://www.iqdb.org
// @grant none
// ==/UserScript==
(function() {
'use strict';
function handlePaste(e) {
var clipboardData, pastedData;
clipboardData = e.clipboardData || window.clipboardData;
pastedData = clipboardData.items[0];
if (pastedData.type.indexOf("image") !== -1) {
e.stopPropagation();
e.preventDefault();
var fileInput = document.getElementById("file");
var formUpload = document.querySelectorAll("input[type=submit]")[0];
/* ? Not working here
fileInput.addEventListener("change", () => {
formUpload.form.submit();
});
*/
fileInput.files = clipboardData.files;
// Automatically submit the pasted image
// (If this is not desired, comment the next line)
formUpload.form.submit();
}
else {
console.log("Not an image, paste event propagated");
}
}
window.addEventListener('paste', handlePaste);
})();