Update Image Loader Placeholder Remover to 1.22.0
- Add specific support for www.independent.co.uk - Fix wrapping <img>s with <a>
This commit is contained in:
parent
29d26e7153
commit
75f8ab9924
|
@ -3,7 +3,7 @@
|
|||
// @namespace blankie-scripts
|
||||
// @match http*://*/*
|
||||
// @grant none
|
||||
// @version 1.21.0
|
||||
// @version 1.22.0
|
||||
// @author blankie
|
||||
// @run-at document-end
|
||||
// @description Removes image loading placeholders
|
||||
|
@ -245,15 +245,14 @@ function unhideElement(element, lazyLoaderClasses) {
|
|||
}
|
||||
|
||||
function wrapImage(img, url) {
|
||||
if (img.closest("a")) {
|
||||
return img;
|
||||
if (img.closest("a") || !url) {
|
||||
return;
|
||||
}
|
||||
|
||||
let wrapper = document.createElement("a");
|
||||
img.replaceWith(wrapper);
|
||||
wrapper.href = url;
|
||||
wrapper.append(img);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
|
@ -331,10 +330,8 @@ function removePlaceholder(img) {
|
|||
}
|
||||
}
|
||||
|
||||
if (originalUrl) {
|
||||
wrapImage(img, originalUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -390,7 +387,6 @@ if (window.location.host === "www.forbes.com") {
|
|||
img.setAttribute(attr.name, attr.value);
|
||||
}
|
||||
img.src = url;
|
||||
img.append(...progressiveImage.childNodes);
|
||||
|
||||
let placeholder = progressiveImage.closest(".image-embed__placeholder");
|
||||
if (placeholder) {
|
||||
|
@ -398,6 +394,26 @@ if (window.location.host === "www.forbes.com") {
|
|||
placeholder.style.paddingTop = 0;
|
||||
}
|
||||
|
||||
progressiveImage.replaceWith(wrapImage(img, url));
|
||||
progressiveImage.replaceWith(img);
|
||||
wrapImage(img, url);
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.independent.co.uk/news/world/americas/abortion-lawsuit-tennessee-idaho-oklahoma-b2410109.html
|
||||
if (window.location.host === "www.independent.co.uk") {
|
||||
for (let ampImg of document.querySelectorAll("amp-img")) {
|
||||
let img = document.createElement("img");
|
||||
for (let attr of ampImg.attributes) {
|
||||
img.setAttribute(attr.name, attr.value);
|
||||
}
|
||||
|
||||
// fix some images blowing past the viewport
|
||||
if (!img.style.width && !img.style.height) {
|
||||
img.style.width = "100%";
|
||||
img.style.height = "auto";
|
||||
}
|
||||
|
||||
ampImg.replaceWith(img);
|
||||
wrapImage(img, img.src);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue