Arras.io - Start Menu Modifier

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

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

  1. // ==UserScript==
  2. // @name Arras.io - Start Menu Modifier
  3. // @version 1.3
  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. //unused element that takes up space
  15. document.querySelector(".menuTabs").remove();
  16.  
  17. //default by having the changelog tab selected instead
  18. document.querySelector("#changelogTabs").children[3].click();
  19.  
  20. //add UI for the server hider
  21. let empties = [],
  22. span = document.createElement("span"),
  23. check = document.createElement("input");
  24. span.innerText = "Hide empty Servers";
  25. span.style.display = "flex";
  26. check.type = "checkbox";
  27. check.checked = !!localStorage.getItem("hideEmptyServers");
  28. check.style.width = "13px";
  29. check.style.height = "13px";
  30. check.style.marginTop = "0px";
  31. check.style.marginBottom = "0px";
  32. check.oninput = () => {
  33. empties.forEach((x) => (x.hidden = check.checked));
  34. localStorage.setItem("hideEmptyServers", check.checked ? " " : "");
  35. };
  36. span.append(check);
  37. document.getElementById("serverFilterRegion").append(span);
  38. document.getElementById("serverFilterRegion").style.display = "flex";
  39.  
  40. let setHeight = (style, x) => style.maxHeight = style.height = x,
  41. doThing = () => {
  42. try {
  43. empties = Array.from(document.getElementById("serverSelector").children).slice(1).filter((x) => x.children[2].innerText.split("/")[0] == "0");
  44. check.oninput();
  45.  
  46. let rules = Array.from(Array.from(document.styleSheets).find((x) => x.href.includes("arras")).rules);
  47.  
  48. for (let ruleName of [".serverSelector", ".slider", ".sliderHolder", ".startMenuHolder", ".startMenuHolder.changelogHolder", ".startMenu", ".mainWrapper", ".shadowScroll", "#startMenuSlidingTrigger", "#startMenuWrapper", "#patchNotes"]) {
  49. let style = rules.find((x) => x.selectorText == ruleName).style;
  50.  
  51. switch (ruleName) {
  52. case ".serverSelector":
  53. setHeight(style, "calc(100% - 159px)");
  54. break;
  55. case ".slider":
  56. setHeight(style, "min-content");
  57. break;
  58. case ".sliderHolder":
  59. setHeight(style, "calc(100% - 50px)");
  60. break;
  61. case ".startMenuHolder":
  62. setHeight(style, "calc(100% - 20px)");
  63. break;
  64. case "#startMenuSlidingTrigger":
  65. style.padding = "10px";
  66. break;
  67. case ".startMenuHolder.changelogHolder":
  68. setHeight(style, "calc(100% - 20px)");
  69. style.display = "block";
  70. break;
  71. case ".startMenu":
  72. setHeight(style, "calc(100%)");
  73. break;
  74. case "#startMenuWrapper":
  75. setHeight(style, "calc(100% - 20px)");
  76. break;
  77. case "#patchNotes":
  78. setHeight(style, "calc(100% - 39px)");
  79. break;
  80. case ".mainWrapper":
  81. style.padding = "20px 20px 20px 20px";
  82. setHeight(style, "calc(100% - 40px)");
  83. break;
  84. case ".shadowScroll":
  85. style.background = style.backgroundSize = style.backgroundColor = style.backgroundRepeat = style.backgroundAttachment = "";
  86. }
  87. }
  88.  
  89. //When you're using document.querySelector()
  90. // https://youtu.be/mdquYEw36TU
  91. setHeight(document.querySelector("#startMenuWrapper > div > div.startMenuHolder.mainHolder > div.sliderHolder > div:nth-child(1)").style, "calc(100% - 315px)");
  92. } catch (err) {}
  93. };
  94.  
  95. doThing();
  96. setInterval(doThing, 1000);