watcher

Watch for added and removed elements and changes to attributes or text content

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/370259-watcher/code/watcher.js?version=612471

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

Author's Description

watcher

Watch a page's DOM for added and removed elements and changes to attributes or text content.


const watcher = new Watcher()

const watch = watcher.add('a[href]', result => {
  console.group(`Added ${result.added.length} links, removed ${result.removed.length} links`)
  for (const a of result.added) {
    console.log(`Added: %o`, a)
  }
  for (const a of result.removed) {
    console.log(`Removed: %o`, a)
  }
  console.groupEnd()
})

watcher.start()