Created
October 15, 2018 20:39
-
-
Save kuckmc01/4013762ad59c134e0e8adafa0d3e90b1 to your computer and use it in GitHub Desktop.
Mutation Observer simple style checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
var container = document.querySelector('paper-dialog.ytd-popup-container'); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
console.log(mutation); | |
if(mutation.attributeName === 'style'){ | |
if(!(container.style.display === 'none')){ | |
console.log('triggering click'); | |
var y = document.querySelector('.yt-confirm-dialog-renderer yt-formatted-string[id="text"]'); | |
y.click(); | |
} | |
} | |
}); | |
}); | |
observer.observe(container, { | |
attributes: true, | |
attributeFilter: ["style"] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment