Arras.io - Start Menu Modifier

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

目前为 2023-10-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Arras.io - Start Menu Modifier
  3. // @version 1.4
  4. // @description Makes the start menu better to look at and adds a setting to hide empty servers.
  5. // @author Taureon
  6. // @run-at document-end
  7. // @match https://arras.io/
  8. // @namespace https://greasyfork.org/users/935758
  9. // ==/UserScript==
  10.  
  11. //What would I need to do to become part of the development team?
  12. //-Taureon
  13.  
  14. //see all servers
  15. let k = JSON.parse(localStorage.getItem('arras.io'));
  16. k.privilege = 10;
  17. localStorage.setItem('arras.io', JSON.stringify(k));
  18.  
  19. window.addEventListener("load", ()=>{
  20.  
  21. //unused element that takes up space
  22. document.querySelector(".menuTabs").remove();
  23.  
  24. //default by having the changelog tab selected instead
  25. document.querySelector("#changelogTabs").children[3].click();
  26.  
  27. //add UI for the server hider
  28. let empties = [],
  29. span = document.createElement("span"),
  30. check = document.createElement("input");
  31. span.innerText = "Hide empty Servers";
  32. span.style.display = "flex";
  33. check.type = "checkbox";
  34. check.checked = !!localStorage.getItem("hideEmptyServers");
  35. check.style.width = "13px";
  36. check.style.height = "13px";
  37. check.style.marginTop = "0px";
  38. check.style.marginBottom = "0px";
  39. check.oninput = () => {
  40. empties.forEach((x) => (x.hidden = check.checked));
  41. localStorage.setItem("hideEmptyServers", check.checked ? " " : "");
  42. };
  43. span.append(check);
  44. document.getElementById("serverFilterRegion").append(span);
  45. document.getElementById("serverFilterRegion").style.display = "flex";
  46.  
  47. let setHeight = (style, x) => style.maxHeight = style.height = x,
  48. doThing = () => {
  49. try {
  50. empties = Array.from(document.getElementById("serverSelector").children).slice(1).filter((x) => x.children[2].innerText.split("/")[0] == "0");
  51. check.oninput();
  52.  
  53. let rules = Array.from(Array.from(document.styleSheets).find((x) => x.href.includes("arras")).rules);
  54.  
  55. for (let ruleName of [".serverSelector", ".slider", ".sliderHolder", ".startMenuHolder", ".startMenuHolder.changelogHolder", ".startMenu", ".mainWrapper", ".shadowScroll", "#startMenuSlidingTrigger", "#startMenuWrapper", "#patchNotes"]) {
  56. let style = rules.find((x) => x.selectorText == ruleName).style;
  57.  
  58. switch (ruleName) {
  59. case ".serverSelector":
  60. setHeight(style, "calc(100% - 159px)");
  61. break;
  62. case ".slider":
  63. setHeight(style, "min-content");
  64. break;
  65. case ".sliderHolder":
  66. setHeight(style, "calc(100% - 50px)");
  67. break;
  68. case ".startMenuHolder":
  69. setHeight(style, "calc(100% - 20px)");
  70. break;
  71. case "#startMenuSlidingTrigger":
  72. style.padding = "10px";
  73. break;
  74. case ".startMenuHolder.changelogHolder":
  75. setHeight(style, "calc(100% - 20px)");
  76. style.display = "block";
  77. break;
  78. case ".startMenu":
  79. setHeight(style, "calc(100%)");
  80. break;
  81. case "#startMenuWrapper":
  82. setHeight(style, "calc(100% - 20px)");
  83. break;
  84. case "#patchNotes":
  85. setHeight(style, "calc(100% - 39px)");
  86. break;
  87. case ".mainWrapper":
  88. style.padding = "20px 20px 20px 20px";
  89. setHeight(style, "calc(100% - 40px)");
  90. break;
  91. case ".shadowScroll":
  92. style.background = style.backgroundSize = style.backgroundColor = style.backgroundRepeat = style.backgroundAttachment = "";
  93. }
  94. }
  95.  
  96. //When you're using document.querySelector()
  97. // https://youtu.be/mdquYEw36TU
  98. setHeight(document.querySelector("#startMenuWrapper > div > div.startMenuHolder.mainHolder > div.sliderHolder > div:nth-child(1)").style, "calc(100% - 315px)");
  99. } catch (err) {}
  100. };
  101.  
  102. doThing();
  103. setInterval(doThing, 1000);
  104.  
  105. });