Roblox Server Finder

Finds an empty server for you to join.

  1. // ==UserScript==
  2. // @name Roblox Server Finder
  3. // @version 1.5
  4. // @description Finds an empty server for you to join.
  5. // @match https://www.roblox.com/games/*
  6. // @author Roblox_Scripter_Tools
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/902751
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. // Gets the game ID
  13. const gid = Number(window.location.pathname.split("/")[2]);
  14. if (!gid) return;
  15. // Gets the game URL
  16. const url = `https://www.roblox.com/games/${gid}`;
  17.  
  18. const searchForGame = function (gid, min, max) {
  19. // Get the game page
  20. let page = Math.round((max + min) / 2);
  21. // Fetch roblox's servers
  22. fetch(`https://www.roblox.com/games/getgameinstancesjson?placeId=${gid}&startindex=${page}`)
  23. // Turn the response into JSON
  24. .then((resp) => resp.json())
  25. .then(function (data) {
  26. if (data.Collection.length < 10 && data.Collection.length > 0) {
  27. let server = data.Collection[data.Collection.length - 1];
  28. if(server.CurrentPlayers.length == 0) {
  29. min = page;
  30. console.log("No people, trying new server:", page);
  31. searchForGame(gid, min, max);
  32. return false;
  33. }
  34. console.log(
  35. "Found empty server:",
  36. server,
  37. "\nCurrent Total Players:",
  38. server.CurrentPlayers.length
  39. );
  40. if (
  41. confirm(
  42. "Found server with " +
  43. server.CurrentPlayers.length +
  44. " players.\nWould you like to join this server?"
  45. )
  46. ) {
  47. try {
  48. eval(server.JoinScript);
  49. } catch (e) {
  50. console.log("Error:", e);
  51. }
  52. } else {
  53. min = page;
  54. console.log("User canceled, trying new server:", page);
  55. searchForGame(gid, min, max);
  56. return false;
  57. }
  58. return true;
  59. } else if (data.Collection.length == 0) {
  60. max = page;
  61. console.log("Page empty, trying new page:", page);
  62. searchForGame(gid, min, max);
  63. } else {
  64. min = page;
  65. console.log("Not empty, trying new server:", page);
  66. searchForGame(gid, min, max);
  67. }
  68. });
  69. };
  70.  
  71. let h3ader = document.createElement("h3");
  72. h3ader.innerHTML = "Empty Server Tool";
  73.  
  74. let btn = document.createElement("span");
  75. btn.id = "-ServerTool-findServer";
  76. btn.onclick = function () {
  77. searchForGame(gid, 0, 10000);
  78. };
  79. btn.innerHTML = "Join Empty Server";
  80. btn.className = "btn-secondary-md";
  81.  
  82. document.getElementById("game-instances").prepend(btn);
  83. document.getElementById("game-instances").prepend(h3ader);
  84. })();