Created
May 14, 2017 21:31
-
-
Save Reedbeta/15b9c4553a8302c316bb0d5a974ec7b2 to your computer and use it in GitHub Desktop.
Letter swapper Greasemonkey script. Just for shits and giggles.
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 Letter Swapper | |
// @namespace reedbeta.com | |
// @version 1 | |
// @grant none | |
// @include * | |
// @exclude https://*.google.com/* | |
// ==/UserScript== | |
var swaps = | |
{ | |
'a': 'e', 'A': 'E', | |
'e': 'a', 'E': 'A', | |
'm': 'n', 'M': 'N', | |
'n': 'm', 'N': 'M', | |
'o': 'u', 'O': 'U', | |
'u': 'o', 'U': 'O', | |
}; | |
// Walk over all text nodes in the document | |
var walker = document.createTreeWalker(document, NodeFilter.SHOW_TEXT); | |
while (n = walker.nextNode()) | |
{ | |
var text = n.nodeValue, newText = ""; | |
for (c of text) | |
{ | |
if (c in swaps) | |
c = swaps[c]; | |
newText += c; | |
} | |
n.nodeValue = newText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment