Question

I'm developing a Google Chrome extension. Its content script should fire every time the page it's on changes, and it does most of the times. I'm using a MutationObserver for this.

However, when I'm on Youtube (and possibly other websites in which I haven't noticed the problem) and I scroll down to load the comments, the MutationObserver doesn't fire. Why is this, shouldn't the DOM have changed?

EDIT: I might want to add that I set the observer to monitor changes in the subtree, childList and attribute of document.body.

Était-ce utile?

La solution

YouTube comments are loaded in an iframe. If you want to watch for mutations of YouTube comments you have to set your content script to be "all_frames": true in the manifest and add the iframe URL pattern to match against.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top