Skip to content

Instantly share code, notes, and snippets.

@firelizzard18
Last active December 25, 2015 03:39
Show Gist options
  • Save firelizzard18/6911804 to your computer and use it in GitHub Desktop.
Save firelizzard18/6911804 to your computer and use it in GitHub Desktop.
clicky
function start() {
var elem = document.createElement('div');
elem.id = 'autoclicker';
elem.style.position = 'absolute';
elem.style.top = '200px';
elem.style.left = '200px';
elem.style['z-index'] = 100000000000;
elem.style.width = '30px';
elem.style.height = '30px';
elem.style.border = '2px solid black';
elem.style['border-radius'] = '15px';
elem.style['background-color'] = 'red';
elem.style['line-height'] = '30px';
elem.style['text-align'] = 'center';
elem.innerHTML = 'AC';
elem.onclick = toggle;
elem.addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);
document.body.appendChild(elem);
window.acint = setInterval(doClick, 1);
window.acel = elem;
window.acc = 0;
}
function toggle() {
window.ac = !window.ac;
if (window.ac)
window.acel.style['background-color'] = 'darkgreen';
else
window.acel.style['background-color'] = 'red';
}
function doClick() {
if (window.ac) {
window.acc++;
fireClick(bigCookie, 100, 100);
}
}
function fireClick(el, x, y) {
var oel = el;
var o = {x:0, y:0};
while (oel != null) {
o.x += el.offsetLeft;
o.y += el.offsetTop;
oel = oel.offsetParent;
}
var ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, window, 1, o.x + x, o.y + y, x, x, false, false, false, false, 0, null);
if (el.fireEvent) {
for (var i = 0; i < 50; i++)
el.fireEvent('on' + etype);
} else {
var ev = document.createEvent('Events');
ev.initEvent('click', true, false);
for (var i = 0; i < 50; i++)
el.dispatchEvent(ev);
}
}
function mouseUp()
{
window.removeEventListener('mousemove', divMove, true);
}
function mouseDown(){
window.addEventListener('mousemove', divMove, true);
}
function divMove(e){
var div = document.getElementById('autoclicker');
div.style.top = e.clientY + 'px';
div.style.left = e.clientX + 'px';
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment