Skip to content

Instantly share code, notes, and snippets.

@askeing
Last active April 8, 2016 09:21
Show Gist options
  • Save askeing/bb3b7b7f14000f0212df172bd44e1847 to your computer and use it in GitHub Desktop.
Save askeing/bb3b7b7f14000f0212df172bd44e1847 to your computer and use it in GitHub Desktop.
MutationObserver of Google Docs
var editor = document.querySelector('.kix-appview-editor');
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
var entry = {
mutation: mutation,
el: mutation.target,
value: mutation.target.textContent,
oldValue: mutation.oldValue
};
console.log('Recording Mutation:', entry);
});
});
var options = {
subtree: true,
childList: true,
attributes: false
};
observer.observe(editor, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment