TweetShootingBot

    @@ -72,6 +72,9 @@ new Bot(); setInterval(function() { + var halfScreen = document.querySelector('.halfScreen'); + if (halfScreen.style.display == 'none') return; + ['.startButton', '.postButton'].forEach(function(selector) { var button = document.querySelector(selector); if (button && button.style.display == 'block') {
  • /*
     * @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.9);
            this.cycle++;
            if (this.cycle %20 == 0) {
                this.controller.startShot();
            }
        }
    };
    
    new Bot();
    
    setInterval(function() {
        var halfScreen = document.querySelector('.halfScreen');
        if (halfScreen.style.display == 'none') return;
    
        ['.startButton', '.postButton'].forEach(function(selector) {
            var button = document.querySelector(selector);
            if (button && button.style.display == 'block') {
                button.dispatchEvent(MouseUtil.click());
            }
        });
    }, 1000);
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/01/12 19:05:37 - 2011-01-12
  2. 2011/01/12 15:15:54 - 2011-01-12
  3. 2011/01/11 14:41:14 - 2011-01-11
  4. 2011/01/11 14:40:17 - 2011-01-11
  5. 2011/01/11 14:33:22 - 2011-01-11
  6. 2011/01/11 14:30:23 - 2011-01-11
  7. 2011/01/11 14:29:23 - 2011-01-11
  8. 2011/01/11 14:21:21 - 2011-01-11
  9. 2011/01/11 14:20:47 - 2011-01-11
  10. 2011/01/11 14:19:16 - 2011-01-11
  11. 2011/01/11 14:16:45 - 2011-01-11