I have a content script that listens for the insertion of text nodes into some websites. It works great except on Facebook. Some of the inserted text nodes are not recognized by the script.
script.js
var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === "characterData") { console.log(mutation.target); } else { for (var x = 0; x < mutation.addedNodes.length; x++) { var node = mutation.addedNodes[x]; if (node.nodeType === Node.TEXT_NODE) { console.log(node); } } } }); }); observer.observe(document, { childList: true, subtree: true, characterData: true });
If I enable logging of all node types, I can see the parent nodes of these text nodes in my log.
Thanks.
source share