From 077ee05b000093b1b9f74ba330eae7d21a17ad06 Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 5 Oct 2023 09:06:08 +1100 Subject: [PATCH] Update Image Loader Placeholder Remover to 1.22.2 - Fix placeholders not being removed on bloomberg.com --- Image Loader Placeholder Remover.user.js | 45 ++++++++++-------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/Image Loader Placeholder Remover.user.js b/Image Loader Placeholder Remover.user.js index 87c2c58..6b27b33 100644 --- a/Image Loader Placeholder Remover.user.js +++ b/Image Loader Placeholder Remover.user.js @@ -4,7 +4,7 @@ // @match http*://*/* // @exclude-match http*://solar.lowtechmagazine.com/* // @grant none -// @version 1.22.1 +// @version 1.22.2 // @author blankie // @run-at document-end // @description Removes image loading placeholders @@ -126,6 +126,9 @@ function getLazyloaderClasses(element) { // Examples of image (though admittedly a hack for cloneLazyloaderTree): // - https://restofworld.org/ // - https://restofworld.org/2023/parent-facing-matchmaking-apps-china/ + // Example of img: + // - https://www.bloomberg.com/news/features/2023-05-11/the-plot-to-steal-the-secret-coke-can-liner-formula + // - https://www.bloomberg.com/news/features/2023-09-28/google-user-data-is-police-s-top-shortcut-for-solving-crimes if (/loading|lazy|responsive|preload|placeholder|image/.test(className)) { classes.push(className); } @@ -138,11 +141,15 @@ function getLazyloaderAttributes(element) { let attributes = []; for (let attr of element.attributes) { + if (attr.name === "class") { + continue; + } // Examples of loading in name: // - https://blog.google/ // - https://blog.google/threat-analysis-group/active-north-korean-campaign-targeting-security-researchers/ - // Example of img in value: - // https://www.bloomberg.com/news/features/2023-05-11/the-plot-to-steal-the-secret-coke-can-liner-formula + // Examples of img in value: + // - https://www.bloomberg.com/news/features/2023-05-11/the-plot-to-steal-the-secret-coke-can-liner-formula + // - https://www.bloomberg.com/news/features/2023-09-28/google-user-data-is-police-s-top-shortcut-for-solving-crimes if (/loading/.test(attr.name) || /img/.test(attr.value)) { attributes.push(attr); } @@ -238,6 +245,9 @@ function unhideElement(element, lazyLoaderClasses) { // - https://restofworld.org/2023/parent-facing-matchmaking-apps-china/ // - https://blog.google/ // - https://blog.google/threat-analysis-group/active-north-korean-campaign-targeting-security-researchers/ + // - https://www.bloomberg.com/news/features/2023-05-11/the-plot-to-steal-the-secret-coke-can-liner-formula + // - https://www.bloomberg.com/news/features/2023-09-28/google-user-data-is-police-s-top-shortcut-for-solving-crimes + // - https://www.washingtonpost.com/nation/2023/07/21/ocean-color-changing-climate-change/ if (classStyle.filter.includes("blur(")) { element.style.filter = classStyle.filter.replaceAll(/blur\(.+?\)/g, "blur(0px)"); } @@ -273,11 +283,7 @@ function removePlaceholder(img) { } let picture = img.closest("picture"); - // Example of a would've been viewable image being blurred: - // https://www.washingtonpost.com/nation/2023/07/21/ocean-color-changing-climate-change/ - if (window.location.host === "www.washingtonpost.com") { - img.parentElement.style.filter = img.parentElement.style.filter.replaceAll(/blur\(.+?\)/g, "blur(0)"); - } + unhideElement(img, getLazyloaderClasses(img)); let srcset = findSrcset(img); let url = findUrl(img); @@ -309,7 +315,6 @@ function removePlaceholder(img) { } } - unhideElement(img, getLazyloaderClasses(img)); if (srcset) { img.srcset = srcset; } @@ -339,25 +344,11 @@ function removePlaceholder(img) { for (let img of document.querySelectorAll("img")) { removePlaceholder(img); } -// the reason we check for mutations for 1s after the page loads is because of