Skip to content

Instantly share code, notes, and snippets.

@zinking
Created July 18, 2017 11:30
Show Gist options
  • Save zinking/d9fe7c566cdb1abde94d58bc742302d5 to your computer and use it in GitHub Desktop.
Save zinking/d9fe7c566cdb1abde94d58bc742302d5 to your computer and use it in GitHub Desktop.
AutoClick
var dispatchMouseEvent = function(target, var_args) {
var e = document.createEvent("MouseEvents");
// If you need clientX, clientY, etc., you can call
// initMouseEvent instead of initEvent
e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
target.dispatchEvent(e);
};
function clickContinue() {
dispatchMouseEvent(element, 'mouseover', true, true);
dispatchMouseEvent(element, 'mousedown', true, true);
dispatchMouseEvent(element, 'click', true, true);
dispatchMouseEvent(element, 'mouseup', true, true);
}
function timeout() {
t = setTimeout(
function() {
console.log('trigger click')
clickContinue()
timeout()
}, 200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment