Update Image Loader Placeholder Remover to 1.18.0

- Add explicit support for www.forbes.com
This commit is contained in:
blankie 2023-09-01 10:05:53 +10:00
parent 127b846b67
commit 169205b341
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 31 additions and 1 deletions

View File

@ -3,7 +3,7 @@
// @namespace blankie-scripts
// @match http*://*/*
// @grant none
// @version 1.17.1
// @version 1.18.0
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -306,4 +306,34 @@ if (window.location.host === "www.wikihow.com") {
video.controls = 1;
video.src = `/video${video.dataset.src}`;
}
}
// https://www.forbes.com/
// https://www.forbes.com/sites/ewanspence/2023/08/30/fairphone-5-preview-android-sustainable-repairable-modular-android/
if (window.location.host === "www.forbes.com") {
for (let progressiveImage of document.querySelectorAll("progressive-image")) {
let url = progressiveImage.getAttribute("src") || progressiveImage.getAttribute("background-image");;
let img = document.createElement("img");
for (let attr of progressiveImage.attributes) {
img.setAttribute(attr.name, attr.value);
}
img.src = url;
img.append(...progressiveImage.childNodes);
let placeholder = progressiveImage.closest(".image-embed__placeholder");
if (placeholder) {
placeholder.style.height = "auto";
placeholder.style.paddingTop = 0;
}
if (!progressiveImage.closest("a")) {
let wrapper = document.createElement("a");
wrapper.href = url;
wrapper.append(img);
progressiveImage.replaceWith(wrapper);
} else {
progressiveImage.replaceWith(img);
}
}
}