Last active
August 29, 2015 14:13
-
-
Save saschanaz/09cb9df956239551fa40 to your computer and use it in GitHub Desktop.
Konachan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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