From e2acd5235b0b004851cc3574c52e01d712e6ce63 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 19 Aug 2022 22:38:49 +0700 Subject: [PATCH] Add support for Vice articles --- Image Loader Placeholder Remover.user.js | 30 +++++++++++++++++++++++- README.md | 4 ++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Image Loader Placeholder Remover.user.js b/Image Loader Placeholder Remover.user.js index 825cd0d..a44920b 100644 --- a/Image Loader Placeholder Remover.user.js +++ b/Image Loader Placeholder Remover.user.js @@ -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; }; \ No newline at end of file diff --git a/README.md b/README.md index 8460d0d..ec247b2 100644 --- a/README.md +++ b/README.md @@ -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