mutation-observer

Simple wrapper for using DOM mutation events

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/7602-mutation-observer/code/mutation-observer.js?version=32979

Author
spiralx
Ratings
0 0 0
Version
0.1.0
Created
Updated
License
N/A
Applies to
All sites

Author's Description

mutation-summary

Library based on DOM Mutation Observers which allows triggering of events on the following conditions:

  • a node is added to the document
  • a node is removed from the document
  • the content of a node is changed
  • an attribute of the node is changed

This library simplifies the process of setting up and using mutation observers e.g.

function updateWidgets(summaries) {
  var widgetSummary = summaries[0];
  widgetSummary.added.forEach(buildNewWidget);
  widgetSummary.removed.forEach(cleanupExistingWidget);
}

var observer = new MutationSummary({
  callback: updateWidgets,
  queries: [{
    element: '[data-widget]'
  }]
});