// ==UserScript== // @name VoidPaste // @namespace http://tampermonkey.net/ // @version 0.1.2 // @description Auto transform pasted image links. // @author voidnyan // @match https://anilist.co/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const imageUrls = [ "https://i.ibb.co" ]; const imageWidth = "320"; let isShiftPressed = false; window.addEventListener("keydown", (event) => { if (event.key !== "Shift") { return; } isShiftPressed = true; }); window.addEventListener("keyup", (event) => { if (event.key !== "Shift") { return; } isShiftPressed = false; }); window.addEventListener("paste", (event) => { const clipboard = event.clipboardData.getData("text/plain").trim(); if (!clipboard.startsWith(imageUrls) || !isShiftPressed){ return; } event.preventDefault(); let transformedClipboard = ""; const urlList = clipboard.split("\n"); for (const url of urlList){ transformedClipboard += `[ img${imageWidth}(${url}) ](${url})\n\n`; } window.document.execCommand('insertText', false, transformedClipboard); }); })();