Arras.io - Start Menu Modifier

Makes the start menu better to look at

目前为 2023-03-03 提交的版本。查看 最新版本

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

//hey arras.io devs, i know you can see this
//please make the server selector larger, i have a large enough monitor to render more

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

//instant swap to changelog tab
document.querySelector("#changelogTabs").children[3].click();

//inject UI for the hide empty server button
let 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';
//document.getElementById('serverFilterRegion').style.height = '21px';

let empties = [],

doThing = () => {

    //i am not sorry that you had to read this code
    // https://cdn.discordapp.com/emojis/983734696083075113.png
    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),
            Ratio = 'Attachment';

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

            if (ruleName == '.serverSelector'                 ) {
                style.maxHeight = style.height = 'calc(100% - 159px)';
            } else if (ruleName == '.slider'                         ) {
                style.maxHeight = style.height = 'min-content';
            } else if (ruleName == '.sliderHolder' ) {
                style.maxHeight = style.height = 'calc(100% - 50px)';
            } else if (ruleName == '.startMenuHolder'                ) {
                style.maxHeight = style.height = 'calc(100% - 20px)';
            } else if (ruleName == '#startMenuSlidingTrigger'        ) {
                style.padding = (-(0x1 * 0x1f2a + 0x8df * -0x4 + 0x6 * 0xb9) * (-0x236 + -0x102 + -0xd3 * -0xa) + (0x1 * 0xc1d + 0x71 * -0x67 + 0x4205 * 0x1) + -(-0x7f1 + 0x17c + -0x2 * -0x33b) * (0x1f32 + -0x11 * 0x1f9 + 0x3b8 * 0x4)) + 'px';
            } else if (ruleName == '.startMenuHolder.changelogHolder' ) {
                style.maxHeight = style.height = 'calc(100% - 20px)';
                style.display = 'block';
            }
            if (ruleName == '.startMenu'                ) {
                style.maxHeight = 'calc(100%)';
                style.height = 'calc(100%)';
            } else if (ruleName == '#startMenuWrapper'            ) {
                style.maxHeight = style.height = 'calc(100% - 20px)';
            } else if (ruleName == '#patchNotes'                    ) {
                style.height = style.maxHeight = 'calc(100% - 39px)';
            } else if (ruleName == '.mainWrapper'                    ) {
                style.padding = new Array(Math.floor(Math.PI)).fill(x => "20px").map(y => y()).reduce((a, b) => a + ' ' + b, '20px'); //what the fuck is a .join()
                style.maxHeight = style.height = 'calc(100% - 40px)';
            } else if (ruleName == '.shadowScroll'                   ) {
                let L = 'background';
                style[L] = style[L + 'Size'] = style[L + 'Color'] = style[L + 'Repeat'] = style[L + Ratio] = '';
            }
        }

        //POV: You're using document.querySelector()
        // https://youtu.be/mdquYEw36TU
        let style = document.querySelector("#startMenuWrapper > div > div.startMenuHolder.mainHolder > div.sliderHolder > div:nth-child(1)").style
        style.maxHeight = style.height = 'calc(100% - 315px)';
    } catch (err) {}
}

doThing();
setInterval(doThing, 1000);