Last active
October 11, 2024 16:58
-
-
Save EleotleCram/07d194aa3bc2bd544df96773c539b17f to your computer and use it in GitHub Desktop.
Tampermonkey script that adds back the dimension overlay in Google Image Search
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 Google Image Search Dimension Overlay | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Tampermonkey script that adds back the dimension overlay in Google Image Search | |
// @author EleotleCram | |
// @match https://www.google.com/* | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
/* global $ */ | |
console.log("Google Image Dimension Overlay activated!"); | |
const styleJson = { | |
position: "absolute", | |
bottom: "0px", | |
background: "#666", | |
color: "white", | |
padding: "4px", | |
}; | |
const styleAttribute = Object.entries(styleJson).map(([k,v]) => `${k}: ${v};`).join(""); | |
window.setInterval(() => { | |
$('[data-ow] a:has(img)').each(function() { | |
const anchorElQ = $(this); | |
if(!anchorElQ.find('>.dim-overlay').length) { | |
const dimElQ = anchorElQ.closest('[data-ow]'); | |
const ow = dimElQ.attr('data-ow'); | |
const oh = dimElQ.attr('data-oh'); | |
$(`<span class="dim-overlay" style="${styleAttribute}">${ow}x${oh}</span>`).appendTo(anchorElQ); | |
} | |
}); | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment