Skip to content

Instantly share code, notes, and snippets.

@rdpanek
Last active January 10, 2020 12:45
Show Gist options
  • Save rdpanek/68ebbcbb5a337e05d067694f7420715f to your computer and use it in GitHub Desktop.
Save rdpanek/68ebbcbb5a337e05d067694f7420715f to your computer and use it in GitHub Desktop.
Auto click on button when is state changed
// 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