Drill / 13 macro's for Agar.io :)

// ==UserScript==
// @name         13 macro's for Agar.io :)
// @version      0.3
// @description  Drill Games
// @match        http://agar.io/*
// @match        http://old.ogarul.io/*
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
document.getElementById("nick").maxLength = "100";

//List instructions
var i = document.getElementById("instructions");
i.innerHTML += "<center>Press & hold <b>W</b> for macro feed</center>";
i.innerHTML += "<center>Press <b>D</b> to tricksplit</center>";
i.innerHTML += "<center>Press <b>A</b> to doublesplit</center>";
i.innerHTML += "<center>Press <b>H</b> for horizontal linesplit position</center>";
i.innerHTML += "<center>Press <b>V</b> for vertical linesplit position</center>";

//Auto-enable show mass/skip stats
//IMPORTANT: You must uncheck showmass/skip stats first then recheck them for it to auto save every time
function autoSet() {
    var m = document.getElementById('showMass'), s = document.getElementById('skipStats');
    if (document.getElementById("overlays").style.display!= "none") {
        document.getElementById("settings").style.display = "block";
        if (m.checked) {m.click();} m.click(); //Show mass
        if (s.checked) {s.click();} s.click(); //Skip stats
    } else setTimeout(autoSet, 100);
}

//Load macros
var canFeed = false;
function keydown(event) {
    switch (event.keyCode) {
        case 87: //Feeding Macro (w)
            canFeed = true;
            feed();
            break;
        case 68: //Tricksplit Macro (t)
            var t = 35;
            for (var t2 = 0; t2 < 4; t2++) {
                setTimeout(split, t);
                t *= 2;
            }
            break;
        case 68: //Tricksplit Macro (e)
            var e = 35;
            for (var e2 = 0; e2 < 4; e2++) {
                setTimeout(split, e);
                e *= 2;
            }
            break;
        case 68: //Tricksplit Macro (4)
            var four = 35;
            for (var four2 = 0; four2 < 4; four2++) {
                setTimeout(split, four);
                four *= 2;
            }
            break;
        case 0: //Triplesplit Macro (a)
            var a = 35;
            for (var a2 = 0; a2 < 3; a2++) {
                setTimeout(split, a);
                a *= 2;
            }
            break;
        case 0: //Triplesplit Macro (3)
            var three = 35;
            for (var three2 = 0; three2 < 3; three2++) {
                setTimeout(split, three);
                three *= 2;
            }
            break;
        case 65: //Doublesplit Macro (d)
            split();
            setTimeout(split, 50);
            break;
        case 65: //Doublesplit Macro (2)
            split();
            setTimeout(split, 50);
            break;
        case 0: //Space Macro (s)
            split();
            break;
        case 0: //Space Macro (1)
            split();
            break;
        case 72: //Horizontal linesplit (h)
            X = window.innerWidth / 2;
            Y = window.innerHeight / 2;
            $("canvas").trigger($.Event("mousemove", {clientX: X, clientY: Y}));
            break;
        case 86: //Vertical linesplit (v)
            X = window.innerWidth / 2;
            Y = window.innerHeight / 2.006;
            $("canvas").trigger($.Event("mousemove", {clientX: X, clientY: Y}));
            break;
    }
}

//When a player lets go of W stop feeding
function keyup(event) {
    if (event.keyCode == 87)
        canFeed = false;
}

//Alias for W key
function feed() {
    if (canFeed) {
        window.onkeydown({keyCode: 87});
        window.onkeyup({keyCode: 87});
        setTimeout(feed, 0);
    }
}

//Alias for space
function split() {
    $("body").trigger($.Event("keydown", { keyCode: 32}));
    $("body").trigger($.Event("keyup", { keyCode: 32}));
}