Last active
March 3, 2021 19:58
-
-
Save szepeviktor/f946409a446f761c63efdb98f217fbc6 to your computer and use it in GitHub Desktop.
KIFLI.hu termékkép nagyító - 🇬🇧 Enlarge ROHLIK.cz product images
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 Kifli nagy képek | |
// @version 0.1.0 | |
// @icon https://www.kifli.hu/favicon/hu/favicon.ico | |
// @run-at document-idle | |
// @grant none | |
// @include https://www.kifli.hu/* | |
// @include https://kifli.hu/* | |
// @include https://www.rohlik.cz/* | |
// ==/UserScript== | |
let currentUrl = document.location.toString(); | |
function _enlargeProductImages() { | |
let images = document.getElementById("productDetail"); | |
if (images == null) { | |
return; | |
} | |
images.querySelectorAll("div[data-gtm-item='product-image'] div > img").forEach(function (image) { | |
// Make CDN enlarge image to fit into carousel | |
image.src = image.src.replaceAll("=500", "=708"); | |
}); | |
}; | |
// Run on initial page load | |
setTimeout(_enlargeProductImages, 1500); | |
document.documentElement.addEventListener("DOMNodeInserted", function (event) { | |
let newUrl = document.location.toString(); | |
if (newUrl == currentUrl) { | |
return; | |
} | |
currentUrl = newUrl; | |
setTimeout(_enlargeProductImages, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original
Maximum size