Skip to content

Instantly share code, notes, and snippets.

@chrisnew
Last active February 9, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisnew/e71b298e622736b8332a47823b693cce to your computer and use it in GitHub Desktop.
Save chrisnew/e71b298e622736b8332a47823b693cce to your computer and use it in GitHub Desktop.
Binnen-I-Remover User Script (Greasemonkey)
// ==UserScript==
// @name Binnen-I-Replacer
// @namespace de.chrisnew.i-replacer
// @version 5
// @match *://*/*
// ==/UserScript==
var preserveElements = ['style', 'script', 'pre', 'code'];
var matcher = /((?![a-zA-z]+)([*_]in|In)(nen)?|\/[Ii]n(nen)?)/g;
function replace_r(elem) {
if ((elem instanceof Element) && preserveElements.indexOf(elem.tagName.toLowerCase()) !== -1) {
return;
}
if (elem instanceof CharacterData) {
if (typeof(elem.nodeValue) === 'string') {
elem.nodeValue = elem.nodeValue.replace(matcher, '');
}
}
var childNodes = elem.childNodes;
if (childNodes) {
for (var i = 0, j = childNodes.length; i < j; i++) {
replace_r(childNodes.item(i));
}
}
}
replace_r(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment