Update Image Loader Placeholder Remover to 1.23.0

- Add support for visibility: {hidden,collapse}
This commit is contained in:
blankie 2023-10-17 15:56:21 +11:00
parent 570b60f927
commit 52a151ae36
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 12 additions and 2 deletions

View File

@ -4,7 +4,7 @@
// @match http*://*/*
// @exclude-match http*://solar.lowtechmagazine.com/*
// @grant none
// @version 1.22.2
// @version 1.23.0
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -150,7 +150,10 @@ function getLazyloaderAttributes(element) {
// Examples of img in value:
// - https://www.bloomberg.com/news/features/2023-05-11/the-plot-to-steal-the-secret-coke-can-liner-formula
// - https://www.bloomberg.com/news/features/2023-09-28/google-user-data-is-police-s-top-shortcut-for-solving-crimes
if (/loading/.test(attr.name) || /img/.test(attr.value)) {
// Examples of image in value:
// - https://www.edinburghlive.co.uk/
// - https://www.edinburghlive.co.uk/news/edinburgh-news/edinburgh-couple-fume-handed-17k-27906242
if (/loading/.test(attr.name) || /img|image/.test(attr.value)) {
attributes.push(attr);
}
}
@ -233,6 +236,13 @@ function unhideElement(element, lazyLoaderClasses) {
document.body.append(toRemove);
let classStyle = getComputedStyle(toExamine);
// Examples of visibility:
// - https://www.edinburghlive.co.uk/
// - https://www.edinburghlive.co.uk/news/edinburgh-news/edinburgh-couple-fume-handed-17k-27906242
if (classStyle.visibility === "hidden" || classStyle.visibility === "collapse") {
element.style.visibility = "visible";
}
// Example of opacity === "0.75":
// https://www.404media.co/welcome-to-404-media/
if (classStyle.opacity !== "1") {