Change HTML in a page
Adapted my earlier answer:
// ==UserScript==
// @name replace text
// @match http://www.imom.com/*
// @run-at document-start
// ==/UserScript==
(() => {
var lookFor = 'Scott Turansky';
var replaceWith = 'Example';
new MutationObserver(mutations => {
for (var i = 0, len = mutations.length; i < len; i++) {
var added = mutations[i].addedNodes;
for (var j = 0, lenAdded = added.length; j < lenAdded; j++) {
var node = added[j];
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.match(lookFor)) {
node.nodeValue = node.nodeValue.replace(lookFor, replaceWith);
} else if (node.nodeType !== Node.ELEMENT_NODE) {
continue;
}
var walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
while (walker.nextNode()) {
var textNode = walker.currentNode;
var text = textNode.nodeValue;
if (text && text.match(lookFor)) {
textNode.nodeValue = text.replace(lookFor, replaceWith);
}
}
}
}
}).observe(document, {childList: true, subtree: true});
})();
Hi ,
Thanks for the reply , but it's not working can you please try it and check why it's not working ?
Thanks a lot !
It's working. You need to install Tampermonkey and then add the script.
Change HTML in a page
Hello ,
Can please somebody help me with a script to edit a website before it's load ?
For example i want to edit on this website : imom.com/7-ways-to-protect-your-child-online
This text : " By: Scott Turansky "
With this one : " By: Example123 "
So when i will enter on that website i will see By: Example123
Thanks a lot !