Last active
March 16, 2018 00:14
-
-
Save gabesumner/a8a3ac290fae1acc02f33479caf2a896 to your computer and use it in GitHub Desktop.
TamperMonkey Heroku Search/Replace Names
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 TamperMonkey Heroku Search/Replace Names | |
// @match https://dashboard.heroku.com/* | |
// @grant none | |
// ==/UserScript== | |
function replaceDreamhouse() { | |
var replaceArry = [ | |
[/dreamhouse/gi, 'pecten'] | |
]; | |
var numTerms = replaceArry.length; | |
var txtWalker = document.createTreeWalker ( | |
document.body, | |
NodeFilter.SHOW_TEXT, | |
{ acceptNode: function (node) { | |
//-- Skip whitespace-only nodes | |
if (node.nodeValue.trim() ) | |
return NodeFilter.FILTER_ACCEPT; | |
return NodeFilter.FILTER_SKIP; | |
} | |
}, | |
false | |
); | |
var txtNode = null; | |
while (txtNode = txtWalker.nextNode () ) { | |
var oldTxt = txtNode.nodeValue; | |
for (var J = 0; J < numTerms; J++) { | |
oldTxt = oldTxt.replace (replaceArry[J][0], replaceArry[J][1]); | |
} | |
txtNode.nodeValue = oldTxt; | |
} | |
setTimeout(function() { | |
replaceDreamhouse(); | |
}, 300); | |
} | |
(function() { | |
var count = 0; | |
replaceDreamhouse(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment