userscripts/Image Loader Placeholder Re...

230 lines
8.3 KiB
JavaScript

// ==UserScript==
// @name Image Loader Placeholder Remover
// @namespace blankie-scripts
// @match http*://*/*
// @grant none
// @version 1.11.0
// @author blankie
// @run-at document-end
// @description Removes image loading placeholders
// ==/UserScript==
// https://closeronline.co.uk
// https://closeronline.co.uk/real-life/news/ever-used-excuses-documented-spreadsheet-man-used-expose-wife-s-lack-sex
function closeronline() {
for (element of document.querySelectorAll(".image-container")) {
let imageElement = element.querySelector("img");
let loadingElement = element.querySelector(".image-loading");
if (imageElement === null || loadingElement === null) {
continue;
}
if (imageElement.attributes["data-src"] === undefined || imageElement.attributes["data-src"].value.length <= 0) {
continue;
}
let url = new URL(imageElement.attributes["data-src"].value, location);
let dontAddLink = element.parentNode.tagName === "A";
if (!dontAddLink) {
let newImageElement = imageElement.cloneNode();
newImageElement.src = url.href;
newImageElement.style.opacity = 100;
newImageElement.style.display = "block";
url.search = "";
let imageWrapper = document.createElement("a");
imageWrapper.href = url.href;
imageWrapper.appendChild(newImageElement);
imageElement.replaceWith(imageWrapper);
} else {
imageElement.src = url.href;
imageElement.style.opacity = 100;
imageElement.style.display = "block";
}
loadingElement.remove();
}
}
// https://www.indiatoday.in
// https://www.indiatoday.in/technology/news/story/vivo-v25-pro-launched-in-india-price-starts-from-rs-35-999-1988971-2022-08-17
function indiatoday() {
for (element of document.querySelectorAll("img.lazyload")) {
if (element.attributes["data-src"] === undefined || element.attributes["data-src"].value.length <= 0) {
continue;
}
let url = new URL(element.attributes["data-src"].value, location);
let dontAddLink = element.parentNode.tagName === "A" ||
(element.parentNode.tagName === "DIV" && element.parentNode.classList.contains("reporter_img"));
if (!dontAddLink) {
let newElement = element.cloneNode();
newElement.src = url.href;
url.search = "";
let wrapper = document.createElement("a");
wrapper.href = url.href;
wrapper.appendChild(newElement);
element.replaceWith(wrapper);
} else {
element.src = url.href;
}
}
}
// 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;
}
}
// https://daramiblog.com/
// https://daramiblog.com/how-to-group-irregular-verbs-for-more-efficient-learning/
function wordpress() {
for (element of document.querySelectorAll("img.lazyload.wp-post-image")) {
if (element.attributes["data-src"] === undefined || element.attributes["data-src"].value.length <= 0) {
continue;
}
element.src = element.attributes["data-src"].value;
element.style.opacity = 100;
}
}
// https://www.pcgamer.com/
// https://www.pcgamer.com/windows-95-theme-for-windows-10/
function pcgamer() {
// look into video carousels?
for (element of document.querySelectorAll("img.lazy-image-van")) {
let originalUrl = element.getAttribute("data-original-mos");
if (originalUrl === null) {
continue;
}
element.src = originalUrl;
}
}
// https://www.wired.com/
// https://www.wired.com/story/researcher-fooled-a-google-ai-into-thinking-a-rifle-was-a-helicopter/
function wired() {
let style = document.createElement("style");
style.innerText = ".gbVKFf {opacity: 1}";
document.head.appendChild(style);
}
// https://www.theautopian.com/
// https://www.theautopian.com/nobody-wants-touch-screen-glove-box-latches-and-it-needs-to-stop-now/
function theautopian() {
for (element of document.querySelectorAll("img[data-jzl-lazy-src]")) {
let originalUrl = element.getAttribute("data-jzl-lazy-src");
if (originalUrl === null) {
continue;
}
element.src = originalUrl;
}
}
// https://www.bleepingcomputer.com/
// https://www.bleepingcomputer.com/news/microsoft/windows-11-snipping-tool-privacy-bug-exposes-cropped-image-content/
function bleepingcomputer() {
for (element of document.querySelectorAll(".b-lazy")) {
const addLink = element.parentNode.tagName !== "A";
const dataSrc = element.getAttribute("data-src");
if (dataSrc === null) {
return;
}
const url = new URL(dataSrc, location);
if (addLink) {
const newElement = element.cloneNode();
newElement.src = url.href;
const wrapper = document.createElement("a");
wrapper.href = url.href;
wrapper.appendChild(newElement);
element.replaceWith(wrapper);
} else {
element.src = url.href;
}
}
}
// https://securelist.com/
// https://securelist.com/cosmicstrand-uefi-firmware-rootkit/106973/
function securelist() {
let style = document.createElement("style");
style.innerText = "img {opacity: 1 !important;}";
document.head.appendChild(style);
}
// https://vulcan.io/blog/
// https://vulcan.io/blog/ai-hallucinations-package-risk
function vulcan() {
for (let element of document.querySelectorAll("img[nitro-lazy-src]")) {
const addLink = element.parentNode.tagName !== "A";
const url = new URL(element.getAttribute("nitro-lazy-src"), location);
if (addLink) {
const newElement = element.cloneNode();
newElement.src = url.href;
const wrapper = document.createElement("a");
wrapper.href = url.href;
wrapper.appendChild(newElement);
element.replaceWith(wrapper);
} else {
element.src = url.href;
}
}
}
// https://blog.joshumax.me/general/2021/08/11/running-doom-on-captioncall.html
// https://knowyourmeme.com/
// https://knowyourmeme.com/memes/saddam-husseins-hiding-place
function joshumax_knowyourmeme() {
for (let element of document.querySelectorAll("img[data-src]")) {
const addLink = element.parentNode.tagName !== "A";
const url = new URL(element.getAttribute("data-src"), location);
if (addLink) {
const newElement = element.cloneNode();
newElement.src = url.href;
const wrapper = document.createElement("a");
wrapper.href = url.href;
wrapper.appendChild(newElement);
element.replaceWith(wrapper);
} else {
element.src = url.href;
}
}
}
switch (location.host) {
case "closeronline.co.uk": closeronline(); break;
case "www.indiatoday.in": indiatoday(); break;
case "www.vice.com": vice(); break;
case "www.pcgamer.com": pcgamer(); break;
case "www.wired.com": wired(); break;
case "www.theautopian.com": theautopian(); break;
case "www.bleepingcomputer.com": bleepingcomputer(); break;
case "securelist.com": securelist(); break;
case "vulcan.io": vulcan(); break;
case "blog.joshumax.me": joshumax_knowyourmeme(); break;
case "knowyourmeme.com": joshumax_knowyourmeme(); break;
default: wordpress(); break;
};