Greasy Fork

headSplix.io

SplixPlus Head Code

目前为 2016-09-16 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.icu/scripts/23245/147637/headSplixio.js

document.getElementById("miniMapPlayer").outerHTML += '<canvas style="position:relative;"width=600 height=800 id="minimapNodes"></canvas>';
minimapNodesCTX = document.getElementById("minimapNodes").getContext("2d");
overrideServer = {
 override: false,
 ip: ""
};
$("#miniMapPlayer").hide();
$("#minimapCanvas").hide();
$("#tutorialCanvas").hide();
CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
    if (w < 2 * r) {
        r = w / 2;
    }
    if (h < 2 * r) {
        r = h / 2;
    }
    this.beginPath();
    this.moveTo(x + r, y);
    this.arcTo(x + w, y, x + w, y + h, r);
    this.arcTo(x + w, y + h, x, y + h, r);
    this.arcTo(x, y + h, x, y, r);
    this.arcTo(x, y, x + w, y, r);
    this.closePath();
    return this;
};

function updateMinimap() {
    try {
        minimapNodesCTX.clearRect(0, 0, minimapNodes.width, minimapNodes.height);
        for (var i = 0; i < players.length; i++) {
            if (!players[i].isDead) {

                var x = players[i].pos[0] / mapSize * 160 + 1.5 - 14;
                var y = players[i].pos[1] / mapSize * 160 + 1.5 - 14;
                minimapNodesCTX.beginPath();
                minimapNodesCTX.roundRect(x, y, 7, 7, 2);
                minimapNodesCTX.lineWidth = 1.3;
                minimapNodesCTX.strokeStyle = "#000";
                minimapNodesCTX.stroke();
                minimapNodesCTX.fillStyle = "#fff";
                minimapNodesCTX.fill();
                minimapNodesCTX.fillText(players[i].name, x - 10, y + 20)
            }
        }
    } catch (e) {}
}
var minimapInterval = setInterval(function() {
    updateMinimap();
}, 100)
MAX_ZOOM = 100000

_getServer = getServer;
getServer = function() {
    if (overrideServer.override) {
     return {ip: "ws://" + overrideServer.ip + "/splix", ping: 1};
     $("#serverIpHolder")[0].innerHTML = "Server Ip: " + overrideServer.ip.split("ws://")[1].split("/splix")[0]
     overrideServer.override = false;
    }
    else {
        a = _getServer();
         $("#serverIpHolder")[0].innerHTML = "Server Ip: " + a.ip.split("ws://")[1].split("/splix")[0]
        return a;
    }
}
_startPingServers = startPingServers
startPingServers = function() {
//$("#serverIp").val(getServer().ip)
_startPingServers();
}
window.connectToSplixServer = function() {
 overrideServer.override = true;
 overrideServer.ip = $(".serverIp").val();
    connectWithTransition();
}

$("#leaderboard").append("<h1>SplixPlus.io</h1><p style='-moz-user-select: text; -khtml-user-select: text; -webkit-user-select: text; -ms-user-select: text; user-select: text;' id='serverIpHolder'>Server Ip: </p>");
$('<br><br><form id="splixPlusForm" class="fancyBox greenBox" style="display:inline-block;margin-left:auto;margin-right:auto;padding:30px" method="get"> <input type="text" style="border:0;outline:0;font-size:20px;padding:8px;box-shadow:1px 1px #155a1c,2px 2px #155a1c,3px 3px #155a1c,4px 4px #155a1c,5px 5px #155a1c,10px 10px 20px rgba(0,0,0,.2);margin:5px;-webkit-appearance:none" class="fancyBox serverIp" maxlength="50" id="serverIp" placeholder="Server Ip"> <input type="button" class="fancyBox" id="joinButton" value="Connect!" onclick="window.connectToSplixServer()"> </form>').insertAfter("#nameForm")