Arras.io - Start Menu Modifier

Makes the start menu better to look at and adds a setting to hide empty servers.

目前為 2023-03-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Arras.io - Start Menu Modifier
// @version      1.3
// @description  Makes the start menu better to look at and adds a setting to hide empty servers.
// @author       Taureon
// @run-at       document-end
// @match        https://arras.io/
// @namespace https://greasyfork.org/users/935758
// ==/UserScript==

//What would I need to do to become part of the development team?
//-Taureon

//unused element that takes up space
document.querySelector(".menuTabs").remove();

//default by having the changelog tab selected instead
document.querySelector("#changelogTabs").children[3].click();

//add UI for the server hider
let empties = [],
    span = document.createElement("span"),
    check = document.createElement("input");
span.innerText = "Hide empty Servers";
span.style.display = "flex";
check.type = "checkbox";
check.checked = !!localStorage.getItem("hideEmptyServers");
check.style.width = "13px";
check.style.height = "13px";
check.style.marginTop = "0px";
check.style.marginBottom = "0px";
check.oninput = () => {
    empties.forEach((x) => (x.hidden = check.checked));
    localStorage.setItem("hideEmptyServers", check.checked ? " " : "");
};
span.append(check);
document.getElementById("serverFilterRegion").append(span);
document.getElementById("serverFilterRegion").style.display = "flex";

let setHeight = (style, x) => style.maxHeight = style.height = x,
    doThing = () => {
        try {
            empties = Array.from(document.getElementById("serverSelector").children).slice(1).filter((x) => x.children[2].innerText.split("/")[0] == "0");
            check.oninput();

            let rules = Array.from(Array.from(document.styleSheets).find((x) => x.href.includes("arras")).rules);

            for (let ruleName of [".serverSelector", ".slider", ".sliderHolder", ".startMenuHolder", ".startMenuHolder.changelogHolder", ".startMenu", ".mainWrapper", ".shadowScroll", "#startMenuSlidingTrigger", "#startMenuWrapper", "#patchNotes"]) {
                let style = rules.find((x) => x.selectorText == ruleName).style;

                switch (ruleName) {
                    case ".serverSelector":
                        setHeight(style, "calc(100% - 159px)");
                        break;
                    case ".slider":
                        setHeight(style, "min-content");
                        break;
                    case ".sliderHolder":
                        setHeight(style, "calc(100% - 50px)");
                        break;
                    case ".startMenuHolder":
                        setHeight(style, "calc(100% - 20px)");
                        break;
                    case "#startMenuSlidingTrigger":
                        style.padding = "10px";
                        break;
                    case ".startMenuHolder.changelogHolder":
                        setHeight(style, "calc(100% - 20px)");
                        style.display = "block";
                        break;
                    case ".startMenu":
                        setHeight(style, "calc(100%)");
                        break;
                    case "#startMenuWrapper":
                        setHeight(style, "calc(100% - 20px)");
                        break;
                    case "#patchNotes":
                        setHeight(style, "calc(100% - 39px)");
                        break;
                    case ".mainWrapper":
                        style.padding = "20px 20px 20px 20px";
                        setHeight(style, "calc(100% - 40px)");
                        break;
                    case ".shadowScroll":
                        style.background = style.backgroundSize = style.backgroundColor = style.backgroundRepeat = style.backgroundAttachment = "";
                }
            }

            //When you're using document.querySelector()
            // https://youtu.be/mdquYEw36TU
            setHeight(document.querySelector("#startMenuWrapper > div > div.startMenuHolder.mainHolder > div.sliderHolder > div:nth-child(1)").style, "calc(100% - 315px)");
        } catch (err) {}
    };

doThing();
setInterval(doThing, 1000);