Skip to content

Instantly share code, notes, and snippets.

@rambuvn
Last active August 28, 2019 08:25
Show Gist options
  • Save rambuvn/9d4f354cf16c3a63468a97de40843db9 to your computer and use it in GitHub Desktop.
Save rambuvn/9d4f354cf16c3a63468a97de40843db9 to your computer and use it in GitHub Desktop.
active mine without mouse click http://minesweeperonline.com/#200
var rbMouse = {
x: 0,
y: 0
};
$(document).on('mousemove', function(evt){
rbMouse = {
x: evt.clientX,
y: evt.clientY
}
});
$(document).on('keydown', function(evt){
var ctrlKey = evt.originalEvent.altKey,
key = evt.originalEvent.which;
//3 flag 50
//2 right click 49
//2+1 open 51
if([49, 50, 51].indexOf(key) >= 0) {
var mouseEvent = new jQuery.Event('mousedown'),
time = 100;
if(key === 51) mouseEvent.button = 0;
if(key === 49) mouseEvent.button = 1;
var element = document.elementFromPoint(rbMouse.x,rbMouse.y);
jQuery(element).trigger(mouseEvent);
mouseEvent.type = 'mousemove';
setTimeout(function(){
jQuery(element).trigger(mouseEvent);
if(key === 50) {
mouseEvent.button = 2;
mouseEvent.type = 'mousedown';
jQuery(element).trigger(mouseEvent);
}
mouseEvent.type = 'mouseup';
jQuery(element).trigger(mouseEvent);
}, time);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment