Skip to content

Instantly share code, notes, and snippets.

@EleotleCram
Last active September 19, 2023 00:11
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save EleotleCram/07d194aa3bc2bd544df96773c539b17f to your computer and use it in GitHub Desktop.
Tampermonkey script that adds back the dimension overlay in Google Image Search
// ==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