Skip to content

Instantly share code, notes, and snippets.

@saschanaz
Last active August 29, 2015 14:13
Show Gist options
  • Save saschanaz/09cb9df956239551fa40 to your computer and use it in GitHub Desktop.
Save saschanaz/09cb9df956239551fa40 to your computer and use it in GitHub Desktop.
Konachan
// ==UserScript==
// @name Konachan
// @namespace sn-konochan-https-imager
// @include https://konachan.com/*
// @version 1.1
// @grant none
// ==/UserScript==
window.snKonachanStatus = "scriptloaded";
document.addEventListener("DOMContentLoaded", () => {
window.snKonachanStatus = "scriptready";
function relativify(element, attributeName, whenError = false) {
let fn = () => {
element[attributeName] = element[attributeName].replace(/^http:/, "");
}
if (whenError)
element.onerror = fn;
else
fn();
}
try {
relativify(document.querySelector("#logo").parentElement, "href");
for (let item of Array.from(document.querySelectorAll("img.preview, img.image"))) {
relativify(item, "src", true);
}
window.snKonachanStatus = "secured";
}
catch (e) { window.snKonachanStatus = `error: ${e.message}`; }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment