Skip to content

Instantly share code, notes, and snippets.

@jimkang
Created October 2, 2013 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimkang/6792883 to your computer and use it in GitHub Desktop.
Save jimkang/6792883 to your computer and use it in GitHub Desktop.
Basic MutationObserver usage.
var mutationObserver = new MutationObserver(
function respondToMutation(mutations, observer) {
if (mutations.length < 1 || mutations[0].addedNodes.length !== 1) {
alert('Could not load a player to play the videos. Sorry.');
}
else {
// Do a thing!
}
}
);
mutationObserver.observe(playerContainerEl, {
attributes: true, childList: true, characterData: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment