Update Image Loader Placeholder Remover to 1.15.0

- Include "placeholder" as a lazyloader class
- Grab images' original URL from theconversation.com
This commit is contained in:
blankie 2023-08-04 18:47:27 +10:00
parent 1b10ebe803
commit c4716c3373
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 9 additions and 2 deletions

View File

@ -3,7 +3,7 @@
// @namespace blankie-scripts
// @match http*://*/*
// @grant none
// @version 1.14.0
// @version 1.15.0
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -112,7 +112,10 @@ function getLazyloaderClasses(element) {
// 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")) {
// Examples of placeholder:
// - https://theconversation.com
// - https://theconversation.com/yall-that-most-southern-of-southernisms-is-going-mainstream-and-its-about-time-193265
if (className.includes("loading") || className.includes("lazy") || className.includes("responsive") || className.includes("preload") || className.includes("placeholder")) {
classes.push(className);;
}
}
@ -169,6 +172,10 @@ function removePlaceholder(img) {
urlObject.search = "";
originalUrl = urlObject.href;
img.closest(".image-container").querySelector(".image-loading").remove();
} else if (window.location.host === "theconversation.com") {
let urlObject = new URL(url, window.location);
urlObject.search = "";
originalUrl = urlObject.href;
}
img.src = url;