Skip to content

Instantly share code, notes, and snippets.

@jD91mZM2
Created October 20, 2017 12:47
Show Gist options
  • Save jD91mZM2/a79220b7f7dfa8d2fd2f190f6d701526 to your computer and use it in GitHub Desktop.
Save jD91mZM2/a79220b7f7dfa8d2fd2f190f6d701526 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Find replace!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description tbodt's idea, but executed poorly
// @author You
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
let replace = {
// "some key \(may include regex\)": "some value"
};
window.onload = function() {
let walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
while (walker.nextNode()) {
let node = walker.currentNode;
for (let key of Object.keys(replace)) {
node.textContent = node.textContent.replace(new RegExp("\\b" + key + "\\b", "gi"), replace[key]);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment