I'm working on a Chrome extension, and it's a simple find-and-replace that grabs text using a tree walker. It works on most sites, but not Facebook or Google. Here's my code:
walk(document.body);
function walk(rootNode)
{
// Find all the text nodes in rootNode
var walker = document.createTreeWalker(
rootNode,
NodeFilter.SHOW_TEXT,
null,
false
),
node;
// Modify each text node's value
while (node = walker.nextNode()) {
handleText(node);
}
}
function handleText(textNode) {
textNode.nodeValue = replaceText(textNode.nodeValue);
}
And then I have another function called replaceText() that runs fine. I suspect the issue is with how document.createTreeWalker() works on Facebook and Google due to their sites' structures. Does anyone know what the issue might be?