Roblox Server Utils

Adds useful features related to roblox servers

  1. // ==UserScript==
  2. // @name Roblox Server Utils
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.1
  5. // @description Adds useful features related to roblox servers
  6. // @author Kugel
  7. // @match http*://www.roblox.com/games/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=roblox.com
  9. // @grant GM_setClipboard
  10. // @grant unsafeWindow
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. const placeId = URL.parse(location.href).pathname.split("/")[2];
  18. if(!placeId) return;
  19. const updateMenu = (oldBtn, jobId) => {
  20. oldBtn.querySelector("a").onclick = (ev) => {
  21. if (ev.target.id === "copy-jobid") {
  22. GM_setClipboard(jobId);
  23. }
  24. };
  25. };
  26. const createMenu = (container, jobId) => {
  27. const oldBtn = container.querySelector("button#rbx-utils");
  28. if (oldBtn) return updateMenu(oldBtn, jobId);
  29. const menuBtn = document.createElement("button");
  30. menuBtn.className = "btn-generic-more-sm";
  31. menuBtn.type = "button";
  32. menuBtn.id = "rbx-utils";
  33. menuBtn.title = "more";
  34.  
  35. const menuSpan = document.createElement("span");
  36. menuSpan.className = "icon-more";
  37. menuBtn.appendChild(menuSpan);
  38. container.appendChild(menuBtn);
  39. const popup = `<div id="game-instance-dropdown-menu" role="tooltip" class="fade in popover bottom" style="display: none; position: relative;"><div class="arrow" style="left: 50%;"></div><div class="popover-content"><ul class="dropdown-menu" role="menu"><li><a class="rbx-private-server-configure" id="copy-jobid">Copy job ID</a></li></ul></div></div>`;
  40. menuBtn.innerHTML += popup;
  41.  
  42. menuBtn.onclick = () => {
  43. const popover = menuBtn.querySelector("div");
  44. popover.style.display = popover.style.display == "none" ? "block" : "none";
  45.  
  46. };
  47.  
  48. menuBtn.querySelector("a").onclick = (ev) => {
  49. if (ev.target.id === "copy-jobid") {
  50. GM_setClipboard(jobId);
  51. }
  52. };
  53. };
  54. const updateRate = 2000;
  55. setInterval(() => {
  56. const joinBtns = document.querySelectorAll("button.game-server-join-btn");
  57. for (const btn of joinBtns) {
  58. const jobId = btn.getAttribute("data-btr-instance-id");
  59. if (!jobId) continue;
  60.  
  61. createMenu(btn.parentElement.parentElement, jobId, placeId);
  62. }
  63. }, updateRate);
  64. const joinInstance = unsafeWindow.Roblox.GameLauncher.joinGameInstance;
  65. if (!joinInstance) return;
  66. const containerHeader = document.querySelector("div#rbx-public-running-games").querySelector("div.container-header");
  67. containerHeader.id = "rbx-utils";
  68. const joinDiv = document.createElement("div");
  69. joinDiv.style.padding = "6px";
  70. const jobInput = document.createElement("input");
  71. jobInput.type = "text";
  72. jobInput.className = "dialog-input";
  73. jobInput.placeholder = "Job ID";
  74. jobInput.style = "overflow: hidden; overflow-wrap: break-word; width: 325px; height: 37px; border: none; outline: none; margin-right: 5px; border-radius: 10px; padding: 5px; text-align: center;";
  75. jobInput.spellcheck = false;
  76. jobInput.autocapitalize = "off";
  77. jobInput.autocomplete = "off";
  78. const joinBtn = document.createElement("button");
  79. joinBtn.type = "submit";
  80. joinBtn.textContent = "Join";
  81. joinBtn.className = "btn-primary-md";
  82. joinBtn.onclick = () => {
  83. const jobId = jobInput.value;
  84. if(jobId === "") alert("No job ID specified. choosing random server.");
  85. joinInstance(placeId, jobId);
  86. };
  87. joinDiv.appendChild(jobInput);
  88. joinDiv.appendChild(joinBtn);
  89. containerHeader.appendChild(joinDiv);
  90.  
  91. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址