Last active
September 7, 2018 05:35
-
-
Save mohemohe/194aaf60448a0aafd3ff26b38d6160f8 to your computer and use it in GitHub Desktop.
π
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 maud.io NSFW | |
// @namespace net.ghippos.hide.nsfw.io.maud.mstdn | |
// @version 1.1 | |
// @description FUCK TWITTER | |
// @author mohemohe <[email protected]> | |
// @match https://mstdn.maud.io/* | |
// @grant none | |
// ==/UserScript== | |
class Mstdn { | |
constructor() { | |
this.mutationObserver = new MutationObserver(() => this.onUpdate()); | |
} | |
start() { | |
this.mutationObserver.observe(document.body, { | |
childList: true, | |
subtree: true, | |
}); | |
} | |
onUpdate() { | |
this.hookNSFW(); | |
} | |
hookNSFW() { | |
const nsfwWarns = document.evaluate(`//span[text()='ι²θ¦§ζ³¨ζ']`, document, null, XPathResult.ANY_TYPE, null); | |
let nsfwWarn; | |
for (;(nsfwWarn = nsfwWarns.iterateNext()) != null;) { | |
const nsfwWarnContainerElement = this.getNSFWWarnContainerElement(nsfwWarn); | |
if (!nsfwWarnContainerElement.classList || nsfwWarnContainerElement.classList.contains('nsfw-eye')) { | |
continue; | |
} | |
nsfwWarnContainerElement.classList.add('nsfw-eye'); | |
nsfwWarnContainerElement.insertAdjacentHTML('afterbegin','<div style="position: absolute; bottom: 0; left: 0; z-index: 114514;">π</div>'); | |
} | |
} | |
getNSFWWarnContainerElement(element) { | |
return ( | |
element.classList.contains('media-gallery') ? | |
element : | |
element.parentElement !== null ? | |
this.getNSFWWarnContainerElement(element.parentElement) : | |
{} | |
); | |
} | |
} | |
new Mstdn().start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment