Created
October 31, 2012 22:02
-
-
Save davetapley/3990220 to your computer and use it in GitHub Desktop.
More theraputic democracy
This file contains 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 Mittens | |
// @namespace http://userscripts.org/users/489276 | |
// @include http* | |
// @version 1 | |
// @grant None | |
// ==/UserScript== | |
// Thanks to: http://stackoverflow.com/a/5494405/21115http://stackoverflow.com/a/5494405/21115 | |
function recursiveReplace(node) { | |
if (node.nodeType == 3) { // text node | |
node.nodeValue = node.nodeValue.replace("Mitt Romney", "Mittens"); | |
console.log(node.nodeValue); | |
} else if (node.nodeType == 1) { // element | |
$(node).contents().each(function () { | |
recursiveReplace(this); | |
}); | |
} | |
} | |
recursiveReplace(document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment