Skip to content

Instantly share code, notes, and snippets.

@85pando
Created March 13, 2016 17:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 85pando/3c2784e69c9d95da5883 to your computer and use it in GitHub Desktop.
Save 85pando/3c2784e69c9d95da5883 to your computer and use it in GitHub Desktop.
// ==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