Last active
January 19, 2022 14:49
-
-
Save Vanawy/1bc300d2bbebb80608da359e12502912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Image preview | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Vanawy Firo <vanawy.dev> | |
// @grant none | |
// @match https://*/* | |
// @match http://*/* | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log("Image preview loaded"); | |
$(document).on("click","img",function(e) { | |
if (!e.ctrlKey) return; | |
e.preventDefault(); | |
let image = new Image(); | |
image.src = e.target.src; | |
let imgDiv = document.createElement("div"); | |
imgDiv.appendChild(image); | |
imgDiv.style = "position: fixed;top: 50%;left: 50%;z-index: 100;transform: translate(-50%, -50%);max-height: 100%;max-width: 100%; background: #777; min-height: 32px;min-width: 32px;"; | |
imgDiv.addEventListener("click", function(e) { | |
console.log(e); | |
e.target.remove(); | |
}); | |
document.body.appendChild(imgDiv); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment