Last active
January 10, 2020 12:45
-
-
Save rdpanek/68ebbcbb5a337e05d067694f7420715f to your computer and use it in GitHub Desktop.
Auto click on button when is state changed
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
// Example 1 | |
const targetElement = document.querySelector('div.ticket_summary__submit div.fortuna_button--yellow') | |
const config = { attributes: true, childList: true, subtree: true }; | |
let callback = function(mutationsList, observer) { | |
let acceptChangesButton = document.querySelector('div.ticket_summary__submit div.fortuna_button--yellow') | |
if ( acceptChangesButton != null ) { | |
console.log('Fortuna yellow button detected!') | |
acceptChangesButton.click() | |
} | |
console.log('Any changes on bet button detected!') | |
}; | |
const observer = new MutationObserver(callback); | |
observer.observe(targetElement, config); | |
// Example 2 | |
setInterval(()=>{let targetButton=document.querySelector('div.ticket_summary__submit div.fortuna_button--yellow');if(targetButton!=null){targetButton.click()}},100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment