Update Image Loader Placeholder Remover to 1.14.0
- Remove lazyloader-related classes from images and their parents
This commit is contained in:
parent
1c576bf970
commit
1b10ebe803
|
@ -3,7 +3,7 @@
|
|||
// @namespace blankie-scripts
|
||||
// @match http*://*/*
|
||||
// @grant none
|
||||
// @version 1.13.0
|
||||
// @version 1.14.0
|
||||
// @author blankie
|
||||
// @run-at document-end
|
||||
// @description Removes image loading placeholders
|
||||
|
@ -90,10 +90,8 @@ function unhideElement(element) {
|
|||
}
|
||||
}
|
||||
|
||||
function isElementLazyloader(element) {
|
||||
if (element.dataset.src) {
|
||||
return true;
|
||||
}
|
||||
function getLazyloaderClasses(element) {
|
||||
let classes = [];
|
||||
|
||||
for (let className of element.classList) {
|
||||
// Examples of loading:
|
||||
|
@ -111,12 +109,15 @@ function isElementLazyloader(element) {
|
|||
// - https://www.vice.com/en/article/dy73n7/ehallpass-1000-thousand-schools-monitor-bathroom
|
||||
// - https://www.wired.com (it's a parent of lazyloaded <img>s)
|
||||
// - https://www.wired.com/story/researcher-fooled-a-google-ai-into-thinking-a-rifle-was-a-helicopter/ (it's a parent of lazyloaded <img>s)
|
||||
if (className.includes("loading") || className.includes("lazy") || className.includes("responsive")) {
|
||||
return true;
|
||||
// Examples of preload:
|
||||
// - https://restofworld.org/
|
||||
// - https://restofworld.org/2023/parent-facing-matchmaking-apps-china/
|
||||
if (className.includes("loading") || className.includes("lazy") || className.includes("responsive") || className.includes("preload")) {
|
||||
classes.push(className);;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,8 +130,13 @@ function removePlaceholder(img) {
|
|||
// Examples of hidden parents:
|
||||
// - https://www.wired.com/
|
||||
// - https://www.wired.com/story/researcher-fooled-a-google-ai-into-thinking-a-rifle-was-a-helicopter/
|
||||
if (isElementLazyloader(parentElement)) {
|
||||
let lazyLoaderClasses = getLazyloaderClasses(parentElement);
|
||||
if (lazyLoaderClasses) {
|
||||
unhideElement(parentElement);
|
||||
// Examples of pages with a blur applied to lazyloader classes:
|
||||
// - https://restofworld.org/
|
||||
// - https://restofworld.org/2023/parent-facing-matchmaking-apps-china/
|
||||
parentElement.classList.remove(...lazyLoaderClasses);
|
||||
}
|
||||
|
||||
parentElement = parentElement.parentElement;
|
||||
|
@ -167,6 +173,7 @@ function removePlaceholder(img) {
|
|||
|
||||
img.src = url;
|
||||
unhideElement(img);
|
||||
img.classList.remove(...getLazyloaderClasses(img));
|
||||
|
||||
if (!hasLinkParent) {
|
||||
let wrapper = document.createElement("a");
|
||||
|
|
Loading…
Reference in New Issue