@@ -63,8 +63,7 @@
do: function() {
this.controller.move(Math.sin(this.cycle / 20) * (this.controller.screen.clientWidth * 0.5 - 24) + (this.controller.screen.clientWidth * 0.5 + 24), this.controller.screen.clientHeight * 0.7);
this.cycle++;
- if (cycle %20 == 0) {
- console.log(cycle);
+ if (this.cycle %20 == 0) {
this.controller.startShot();
}
}
/*
* @title TweetShootingBot
* @description TweetShootingBot
* @include http://tweetshooting.appspot.com/
* @license MIT License
* @require
*/
var MouseUtil = { };
['mousemove', 'mousedown', 'mouseup', 'click'].forEach(function (method) {
MouseUtil[method] = function(x, y) {
if (!x) x = 0;
if (!y) y = 0;
var event = document.createEvent("MouseEvents");
event.initMouseEvent(method, true, false, window,
0, x, y, x, y, false, false, true, false, 0, null );
return event;
}
});
var Controller = function() {
this.screen = document.querySelector('.tpLayer');
this.x = this.screen.clientWidth / 2;
this.y = this.screen.clientHeight / 3 * 2;
}
Controller.prototype = {
move: function(x, y) {
this.x = x;
this.y = y;
this.dispatch(MouseUtil.mousemove(this.x, this.y));
},
moveRelative: function(x, y) {
this.x += x;
this.y += y;
this.dispatch(MouseUtil.mousemove(this.x, this.y));
},
startShot: function() {
this.dispatch(MouseUtil.mousedown(this.x, this.y));
},
stopShot: function() {
this.dispach(MouseUtil.mouseup(this.x, this.y));
},
dispatch: function(event) {
this.screen.dispatchEvent(event);
}
};
var Bot = function(player) {
this.controller = new Controller();
this.cycle = 0;
this.run();
}
Bot.prototype = {
run: function() {
this.controller.startShot();
var self = this;
setInterval(function() {
self.do();
}, 50);
},
do: function() {
this.controller.move(Math.sin(this.cycle / 20) * (this.controller.screen.clientWidth * 0.5 - 24) + (this.controller.screen.clientWidth * 0.5 + 24), this.controller.screen.clientHeight * 0.7);
this.cycle++;
if (this.cycle %20 == 0) {
this.controller.startShot();
}
}
};
new Bot();