Last active
February 9, 2017 16:24
-
-
Save chrisnew/e71b298e622736b8332a47823b693cce to your computer and use it in GitHub Desktop.
Binnen-I-Remover User Script (Greasemonkey)
This file contains hidden or 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 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