Created
October 17, 2014 18:11
-
-
Save brianloveswords/222a638fd8b783f7d56d 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 SJW→skeleton | |
// @namespace http://bjb.io | |
// @include http://reddit.com/* | |
// @include https://reddit.com/* | |
// @include http://8chan.co/* | |
// @include https://8chan.co/* | |
// @include https://archive.today/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
document.addEventListener('DOMContentLoaded', function () { | |
// I stole most of this from | |
// https://github.com/alexhong/sjw-to-skeleton/blob/master/Source/content_script.js | |
walk(document.body); | |
function walk(node) { | |
var child, next; | |
switch (node.nodeType) { | |
case 1: // Element | |
case 9: // Document | |
case 11: // Document fragment | |
child = node.firstChild; | |
while (child) { | |
next = child.nextSibling; | |
walk(child); | |
child = next; | |
} | |
break; | |
case 3: // Text node | |
if (node.parentElement.tagName.toLowerCase() != 'script') { | |
handleText(node); | |
} | |
break; | |
} | |
} | |
function handleText(textNode) { | |
textNode.nodeValue = textNode.nodeValue | |
.replace(/\bsjw(s?)\b/gi, 'skeleton$1') | |
.replace(/\bAn skeleton(s?)\b/g, 'A skeleton$1') | |
.replace(/\ban skeleton(s?)\b/g, 'a skeleton$1') | |
// feel free to add your own! | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment