diff --git a/Image Loader Placeholder Remover.user.js b/Image Loader Placeholder Remover.user.js index 41156f2..0cc2024 100644 --- a/Image Loader Placeholder Remover.user.js +++ b/Image Loader Placeholder Remover.user.js @@ -3,7 +3,7 @@ // @namespace blankie-scripts // @match http*://*/* // @grant none -// @version 1.21.0 +// @version 1.22.0 // @author blankie // @run-at document-end // @description Removes image loading placeholders @@ -245,15 +245,14 @@ function unhideElement(element, lazyLoaderClasses) { } function wrapImage(img, url) { - if (img.closest("a")) { - return img; + if (img.closest("a") || !url) { + return; } let wrapper = document.createElement("a"); img.replaceWith(wrapper); wrapper.href = url; wrapper.append(img); - return wrapper; } @@ -331,9 +330,7 @@ function removePlaceholder(img) { } } - if (originalUrl) { - wrapImage(img, originalUrl); - } + wrapImage(img, originalUrl); } @@ -390,7 +387,6 @@ if (window.location.host === "www.forbes.com") { img.setAttribute(attr.name, attr.value); } img.src = url; - img.append(...progressiveImage.childNodes); let placeholder = progressiveImage.closest(".image-embed__placeholder"); if (placeholder) { @@ -398,6 +394,26 @@ if (window.location.host === "www.forbes.com") { placeholder.style.paddingTop = 0; } - progressiveImage.replaceWith(wrapImage(img, url)); + progressiveImage.replaceWith(img); + wrapImage(img, url); + } +} + +// https://www.independent.co.uk/news/world/americas/abortion-lawsuit-tennessee-idaho-oklahoma-b2410109.html +if (window.location.host === "www.independent.co.uk") { + for (let ampImg of document.querySelectorAll("amp-img")) { + let img = document.createElement("img"); + for (let attr of ampImg.attributes) { + img.setAttribute(attr.name, attr.value); + } + + // fix some images blowing past the viewport + if (!img.style.width && !img.style.height) { + img.style.width = "100%"; + img.style.height = "auto"; + } + + ampImg.replaceWith(img); + wrapImage(img, img.src); } } \ No newline at end of file