Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (mutationObserver) mutationObserver.disconnect()
- var mutationObserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (mutation.addedNodes.length === 0 && mutation.removedNodes.length === 0 && mutation.attributeName === "class") {
- mutation.target.dispatchEvent(new CustomEvent('classChanged', {bubbles: true, detail: {}}))
- }
- })
- })
- mutationObserver.observe(document.documentElement, {attributes: true, subtree: true})
- function callback() {
- console.log(this, arguments)
- }
- var candidates = document.querySelectorAll('.candidate')
- for(var i = 0; i < candidates.length; i++) {
- candidates[i].addEventListener('classChanged', callback, false)
- }
Add Comment
Please, Sign In to add comment