Created
March 13, 2016 17:54
-
-
Save 85pando/3c2784e69c9d95da5883 to your computer and use it in GitHub Desktop.
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 Replace Text | |
// @namespace Replace text | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
var replacements, | |
regex, | |
key, | |
textnodes, | |
node, | |
s; | |
replacements = { | |
'AfD': '卐', | |
'AFD': '卐', | |
'afd': '卐', | |
}; | |
regex = { | |
}; | |
for (key in replacements) { | |
regex[key] = new RegExp(key, 'g'); | |
} | |
textnodes = document.evaluate('//body//text()', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = 0; i < textnodes.snapshotLength; i++) { | |
node = textnodes.snapshotItem(i); | |
s = node.data; | |
for (key in replacements) { | |
s = s.replace(regex[key], replacements[key]); | |
} | |
node.data = s; | |
} | |
}) (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment