Skip to content

Instantly share code, notes, and snippets.

@davetapley
Created October 31, 2012 22:02
Show Gist options
  • Save davetapley/3990220 to your computer and use it in GitHub Desktop.
Save davetapley/3990220 to your computer and use it in GitHub Desktop.
More theraputic democracy
// ==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