Skip to content

Instantly share code, notes, and snippets.

@brianloveswords
Created October 17, 2014 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brianloveswords/222a638fd8b783f7d56d to your computer and use it in GitHub Desktop.
Save brianloveswords/222a638fd8b783f7d56d to your computer and use it in GitHub Desktop.
// ==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