Zaikantos / MT - ServerLinks

// ==UserScript==
// @name         MT - ServerLinks
// @version      1.2
// @description  Add links to all servers on the left side of the top navigation bar
// @author       Zaikantos
// @match        *://*.minethings.com/*
// @exclude      *://*.minethings.com/app/webroot/forums/*
// @exclude      *://*.wiki.minethings.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var navBar = document.getElementById("nav");
    navBar.style.marginLeft = "0px";
    
    //get url without the servername
    var currentUrl = window.location.href;
    var strippedUrl = currentUrl.substring(currentUrl.indexOf('.'), currentUrl.length);

    var servers = ["Aso", "Bromo", "Calbuco", "Dempo", "Ebeko", "Fogo", "Gallego"].reverse();
    servers.forEach(createElement);
    
    //make navBar align with how it is without the script
    navBar.children[7].style.marginLeft = "3px";

    //For input String serverName, add an element to the left side of the navBar that links to that server
    function createElement(serverName) {
        var element = document.createElement("LI");
        var a = document.createElement("a");
        //size of each server link box
        element.style.width="17px";
        element.style.height="47px";

        //make a's contents the first letter of the server
        var letter = serverName.substring(0,1);
        a.textContent = letter;
        
        //make a link to the server, unless we are on that server
        if(currentUrl.substring(7, 8) == letter.toLowerCase()) {
            //same server, do nothing
        } else {
            a.setAttribute('href', "http://" + serverName + strippedUrl);
        }

        //make link be the entire element
        a.style.display = "block";
        a.style.width = "100%";
        a.style.height = "100%";
        a.style.color = "white";

        //styling
        a.style.textDecoration = "none";
        a.style.textAlign = "center";

        element.appendChild(a);
        navBar.insertBefore(element, navBar.firstChild);
    }
})();