Add support for Vice articles

This commit is contained in:
blankie 2022-08-19 22:38:49 +07:00
parent 2d3ee70def
commit e2acd5235b
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 31 additions and 3 deletions

View File

@ -3,8 +3,9 @@
// @namespace blankie-scripts
// @match http*://closeronline.co.uk/*
// @match http*://www.indiatoday.in/*
// @match http*://www.vice.com/*
// @grant none
// @version 1.0
// @version 1.1
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
@ -70,8 +71,35 @@ function indiatoday() {
}
}
// TODO add support for home page, i'm too lazy
// https://www.vice.com/en/article/dy73n7/ehallpass-1000-thousand-schools-monitor-bathroom
function vice() {
for (element of document.querySelectorAll(".lazyloader--lowres")) {
let sourceElement = element.querySelector("source");
let imgElement = element.querySelector("img");
if (sourceElement === null || imgElement === null) {
continue;
}
let url = new URL(sourceElement.srcset, location);
url.search = "";
let newImgElement = imgElement.cloneNode();
newImgElement.src = url.href;
newImgElement.style.filter = "none";
let imgWrapper = document.createElement("a");
imgWrapper.href = url.href;
imgWrapper.appendChild(newImgElement);
imgElement.replaceWith(imgWrapper);
for (sourceElement of element.querySelectorAll("source")) {
sourceElement.remove();
}
element.style.opacity = 1;
}
}
switch (location.host) {
case "closeronline.co.uk": closeronline(); break;
case "www.indiatoday.in": indiatoday(); break;
case "www.vice.com": vice(); break;
};

View File

@ -18,8 +18,8 @@ Hacky script to disable the client-side file limit per tab
## Image Loader Placeholder Remover
Removes image loading placeholders from https://closertoday.co.uk and
https://www.indiatoday.in
Removes image loading placeholders from https://closertoday.co.uk,
https://www.indiatoday.in, and https://www.vice.com (article only).
## nightly.link buttons