d2k1 / D918 slither.io

// ==UserScript==
// @name         D918 slither.io
// @namespace    D918
// @version      1.03
// @description  Shows useful info. TODO: server connector
// @author       D918
// @match        http://slither.io/*
// @grant        none
// ==/UserScript==

//Creator D918 :)

(function(w) {

//Append div
function appendDiv(id, className, style) {
        var div = document.createElement("div");
        if (id) {
            div.id = id;
        }
        if (className) {
            div.className = className;
        }
        if (style) {
            div.style = style;
        }
        document.body.appendChild(div);
    }

//Set leaderboard text
function lb() {
    if (w.lbh) w.lbh.textContent = "D918";
    else setTimeout(lb, 0);
}

//szymy's zoom func
function zoom(e) {
        if (!w.gsc) {
            return;
        }
        w.gsc *= Math.pow(0.9, e.wheelDelta / -120 || e.detail / 2 || 0);
}

    var iStyle = 'position: fixed; top: 10px; left: 15px; padding: 0px 8px; font-family: Tahoma; color: rgb(255, 255, 255); z-index: 9999; border-radius: 5px; min-height: 15px; min-width: 200px; background-color: rgba(0, 0, 0, 0.6);',
        data = null,
        v = 3;

    //Append divs
    appendDiv("D918", "D918", iStyle + "top: 100px;");
    data = document.getElementById("D918");

    //On key down...
    w.onkeydown = function(e) {
        if (w.playing) if (e.keyCode == 16) w.setAcceleration(true);
        };

    //On key up...
    w.onkeyup = function(e) {
        if (w.playing) {
            if (e.keyCode == 16) w.setAcceleration(false);
            if (e.keyCode == 86) w.open("https://www.google.com.mx/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwiCnI-W557MAhVO6WMKHRvVBTUQFgg0MAM&url=https%3A%2F%2Fes.wikipedia.org%2Fwiki%2FFuck_you&usg=AFQjCNFjJcLA_XYJnnqWmIfhWgQT_mc-ZA&sig2=HpZbf3Y6PCbbLlPNI_jZDg", "_blank");
            if (e.keyCode == 66) w.open("http://iKnew.xyz/", "_blank");
            if (e.keyCode == 78) w.open("https://www.google.com.mx/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwiCnI-W557MAhVO6WMKHRvVBTUQFgg0MAM&url=https%3A%2F%2Fes.wikipedia.org%2Fwiki%2FFuck_you&usg=AFQjCNFjJcLA_XYJnnqWmIfhWgQT_mc-ZA&sig2=HpZbf3Y6PCbbLlPNI_jZDg");
        }
    };

    //szymy's zoom
    if (/firefox/i.test(navigator.userAgent)) {
            document.addEventListener("DOMMouseScroll", zoom, false);
        } else {
            document.body.onmousewheel = zoom;
        }

    //Keep updating data
    function dt() {
             if (w.playing) {
       
                 if (data) data.innerHTML = '<div id="D918" className="D918" style="font-family: Papyrus; font-size: 20px; color: red;"><b>D918 ' + v + '</b></div>' + "<br>" +
                    '<div id="finehacks sucks" className="Saludos desde México" style="color: yellow;"><b>D918 BEST HACKEER</b></div>' + "<br>" +
                    '<div id="slitherio" className="D918" style="color: bisque; font-size: 17px"><sup><b>special thanks to dadagamer</b></sup></div>' + "<br>" +
                    '<div id="Hotkeys" className="D918" style="color: green;">[SHIFT] - Accelerate<br><br><br><br>[Mouse wheel] - Zoom</div>' + "<br>" +
                     "X: " + ~~w.snake.xx + "<br>" +
                     "Y: " + ~~w.snake.yy + "<br>" +
                     "Rank: " + w.rank + "/" + w.snake_count + "<br>" +
                     "Server IP: " + w.bso.ip;
             }
        setTimeout(dt, 0);
    }

    dt();
    lb();

})(window);