Update Image Loader Placeholder Remover to 1.12.1
- Properly check if an image has a link parent. This can be seen on https://legendsoflocalization.com/an-inside-look-at-video-game-control-codes/#related
This commit is contained in:
parent
dcd9c57744
commit
0bbf671a66
|
@ -3,7 +3,7 @@
|
||||||
// @namespace blankie-scripts
|
// @namespace blankie-scripts
|
||||||
// @match http*://*/*
|
// @match http*://*/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// @version 1.12.0
|
// @version 1.12.1
|
||||||
// @author blankie
|
// @author blankie
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// @description Removes image loading placeholders
|
// @description Removes image loading placeholders
|
||||||
|
@ -22,7 +22,7 @@ function closeronline() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let url = new URL(imageElement.attributes["data-src"].value, location);
|
let url = new URL(imageElement.attributes["data-src"].value, location);
|
||||||
let dontAddLink = element.parentNode.tagName === "A";
|
let dontAddLink = hasLinkParent(element);
|
||||||
|
|
||||||
if (!dontAddLink) {
|
if (!dontAddLink) {
|
||||||
let newImageElement = imageElement.cloneNode();
|
let newImageElement = imageElement.cloneNode();
|
||||||
|
@ -52,8 +52,7 @@ function indiatoday() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let url = new URL(element.attributes["data-src"].value, location);
|
let url = new URL(element.attributes["data-src"].value, location);
|
||||||
let dontAddLink = element.parentNode.tagName === "A" ||
|
let dontAddLink = hasLinkParent(element);
|
||||||
(element.parentNode.tagName === "DIV" && element.parentNode.classList.contains("reporter_img"));
|
|
||||||
|
|
||||||
if (!dontAddLink) {
|
if (!dontAddLink) {
|
||||||
let newElement = element.cloneNode();
|
let newElement = element.cloneNode();
|
||||||
|
@ -145,7 +144,7 @@ function theautopian() {
|
||||||
// https://www.bleepingcomputer.com/news/microsoft/windows-11-snipping-tool-privacy-bug-exposes-cropped-image-content/
|
// https://www.bleepingcomputer.com/news/microsoft/windows-11-snipping-tool-privacy-bug-exposes-cropped-image-content/
|
||||||
function bleepingcomputer() {
|
function bleepingcomputer() {
|
||||||
for (element of document.querySelectorAll(".b-lazy")) {
|
for (element of document.querySelectorAll(".b-lazy")) {
|
||||||
const addLink = element.parentNode.tagName !== "A";
|
const addLink = !hasLinkParent(element);
|
||||||
const dataSrc = element.getAttribute("data-src");
|
const dataSrc = element.getAttribute("data-src");
|
||||||
if (dataSrc === null) {
|
if (dataSrc === null) {
|
||||||
return;
|
return;
|
||||||
|
@ -177,7 +176,7 @@ function securelist() {
|
||||||
// https://vulcan.io/blog/ai-hallucinations-package-risk
|
// https://vulcan.io/blog/ai-hallucinations-package-risk
|
||||||
function vulcan() {
|
function vulcan() {
|
||||||
for (let element of document.querySelectorAll("img[nitro-lazy-src]")) {
|
for (let element of document.querySelectorAll("img[nitro-lazy-src]")) {
|
||||||
const addLink = element.parentNode.tagName !== "A";
|
const addLink = !hasLinkParent(element);
|
||||||
const url = new URL(element.getAttribute("nitro-lazy-src"), location);
|
const url = new URL(element.getAttribute("nitro-lazy-src"), location);
|
||||||
|
|
||||||
if (addLink) {
|
if (addLink) {
|
||||||
|
@ -199,7 +198,7 @@ function vulcan() {
|
||||||
// https://knowyourmeme.com/memes/saddam-husseins-hiding-place
|
// https://knowyourmeme.com/memes/saddam-husseins-hiding-place
|
||||||
function datasrc() {
|
function datasrc() {
|
||||||
for (let element of document.querySelectorAll("img[data-src]")) {
|
for (let element of document.querySelectorAll("img[data-src]")) {
|
||||||
const addLink = element.parentNode.tagName !== "A";
|
const addLink = !hasLinkParent(element);
|
||||||
const url = new URL(element.getAttribute("data-src"), location);
|
const url = new URL(element.getAttribute("data-src"), location);
|
||||||
|
|
||||||
if (addLink) {
|
if (addLink) {
|
||||||
|
@ -215,6 +214,16 @@ function datasrc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasLinkParent(element) {
|
||||||
|
while (element) {
|
||||||
|
if (element.localName === "a") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
element = element.parentElement;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (location.host) {
|
switch (location.host) {
|
||||||
case "closeronline.co.uk": closeronline(); break;
|
case "closeronline.co.uk": closeronline(); break;
|
||||||
case "www.indiatoday.in": indiatoday(); break;
|
case "www.indiatoday.in": indiatoday(); break;
|
||||||
|
|
Loading…
Reference in New Issue