Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var dispatchMouseEvent = function(target, var_args) {
- var e = document.createEvent("MouseEvents");
- e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
- target.dispatchEvent(e);
- };
- function mouseClick(target) {
- dispatchMouseEvent(target, 'mousedown', true, true);
- target.focus();
- dispatchMouseEvent(target, 'mouseup', true, true);
- };
- var ex = document.getElementById("example");
- var ctx = ex.getContext("2d");
- function check() {
- if (ctx.getImageData(0,0,1,1).data[0] === 0) {
- mouseClick(ex);
- }
- setTimeout(function(){
- check();
- }, 1);
- };
- check();
Advertisement
Add Comment
Please, Sign In to add comment