Update Image Loader Placeholder Remover to 1.23.3

- Fix handling www.chaobunnyarts.com
This commit is contained in:
blankie 2024-01-09 11:09:57 +11:00
parent ad095620d9
commit 38c67e2be5
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 12 additions and 5 deletions

View File

@ -4,7 +4,7 @@
// @match http*://*/*
// @exclude-match http*://solar.lowtechmagazine.com/*
// @grant none
// @version 1.23.2
// @version 1.23.3
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -16,7 +16,9 @@ const URL_RE_STR = "(?:https?://|\\.{0,2}/)\\S+";
const URL_RE = new RegExp(`^${URL_RE_STR}$`);
const SRCSET_COMPONENT = `${URL_RE_STR}(?:\\s+\\d+w|\\s+\\d+(?:\\.\\d+)?x)?`;
const SRCSET_RE = new RegExp(`^${SRCSET_COMPONENT}(?:,\\s*${SRCSET_COMPONENT})*$`);
// Example of a trailing comma:
// - https://www.chaobunnyarts.com/product/shipping-upgrade-tracked-sticker-shipping
const SRCSET_RE = new RegExp(`^${SRCSET_COMPONENT}(?:,\\s*${SRCSET_COMPONENT})*,?$`);
let cachedCSSProperties = new Map();
@ -110,7 +112,9 @@ function findSrcset(element) {
// Examples of data-srcset:
// - https://www.cbsnews.com/
// - https://www.cbsnews.com/news/leonard-mack-exonerated-47-years-after-wrongful-rape-conviction/
if (/srcset/.test(attr.name) && attr.name !== "srcset" && SRCSET_RE.test(attr.value)) {
// - https://www.chaobunnyarts.com/
// - https://www.chaobunnyarts.com/product/shipping-upgrade-tracked-sticker-shipping
if (/srcset/.test(attr.name) && attr.name !== "srcset" && SRCSET_RE.test(attr.value.trim())) {
return attr.value;
}
}
@ -157,10 +161,13 @@ 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:
// Examples 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)) {
// Examples of blur;
// - https://www.chaobunnyarts.com/
// - https://www.chaobunnyarts.com/product/shipping-upgrade-tracked-sticker-shipping
if (/loading|lazy|responsive|preload|placeholder|image|blur/.test(className)) {
classes.push(className);
}
}