Update Image Loader Placeholder Remover to 1.16.1

- Fix displaying images inside <picture>s
This commit is contained in:
blankie 2023-08-11 16:25:46 +10:00
parent 4f5bc106b7
commit b2f18e2841
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 11 additions and 7 deletions

View File

@ -3,7 +3,7 @@
// @namespace blankie-scripts
// @match http*://*/*
// @grant none
// @version 1.16.0
// @version 1.16.1
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -151,6 +151,7 @@ function removePlaceholder(img) {
parentElement = parentElement.parentElement;
}
let picture = img.closest("picture");
let url = findUrl(img);
if (!url) {
@ -160,8 +161,6 @@ function removePlaceholder(img) {
if (window.location.host === "www.vice.com") {
let picture = img.parentElement;
img.style.filter = "none";
picture.style.opacity = 1;
@ -170,10 +169,6 @@ function removePlaceholder(img) {
originalUrl = urlObject.href;
urlObject.search = "?resize=1024:*";
url = urlObject.href;
for (let source of picture.querySelectorAll("source")) {
source.remove();
}
} else if (window.location.host === "closeronline.co.uk") {
let urlObject = new URL(url, window.location);
urlObject.search = "";
@ -191,6 +186,15 @@ function removePlaceholder(img) {
// https://legendsoflocalization.com/japans-mysterious-love-of-the-word-lets/#why-lets-is-so-common
//img.classList.remove(...getLazyloaderClasses(img));
// apparently, remaining <source>s can fuck up image rendering (firefox still thinks that the <img> contains an empty image?)
// https://gizmodo.com/reddit-news-blackout-protest-is-finally-over-reddit-won-1850707509
// also, the above vice.com-specific condition had the below code
if (picture) {
for (let source of picture.querySelectorAll("source")) {
source.remove();
}
}
if (!hasLinkParent) {
let wrapper = document.createElement("a");
img.replaceWith(wrapper);