Skip to content

Instantly share code, notes, and snippets.

@techsin
Created July 1, 2019 15:32
Show Gist options
  • Save techsin/a19dd548f6d193129dac74c22972fc77 to your computer and use it in GitHub Desktop.
Save techsin/a19dd548f6d193129dac74c22972fc77 to your computer and use it in GitHub Desktop.
Reaction time sens clicker
var ele = document.querySelector('.test-standard.reaction-time-test');
var config = { attributes: true };
var event = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true
});
var callback = function (mutationsList, observer) {
for (var mutation of mutationsList) {
if (mutation.type == 'attributes' && mutation.attributeName == 'class' && ele.classList.contains('view-go')) {
console.log('clicked')
ele.dispatchEvent(event);
}
}
};
var observer = new MutationObserver(callback);
observer.observe(ele, config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment