Roblox small server joiner

Try to take over the world!

Tính đến 29-11-2021. Xem phiên bản mới nhất.

// ==UserScript==
// @name         Roblox small server joiner
// @namespace    https://popcat.click
// @version      1.4
// @description  Try to take over the world!
// @author       https://github.com/ahmadinator
// @match        https://web.roblox.com/games/*
// @match        https://www.roblox.com/games/*
// @icon         https://www.google.com/s2/favicons?domain=roblox.com
// @license      MIT
// @grant        none
// ==/UserScript==
(function() {
    'use strict';

    Number.prototype.between = function(a, b) {
        var min = Math.min.apply(Math, [a, b]),
            max = Math.max.apply(Math, [a, b]);
        return this > min && this < max;
    };

    let SI = 0;
    let gameIdString = window.location.pathname.split('/')[2];

    function join(gameInstances) {
        let bestServer = 0;
        let e = 0;
        for (let server of gameInstances.Collection) {
            e += 1;
            let serverPlayerCount = server.CurrentPlayers.length;
            let maxPlayers = server.Capacity;
            let serverId = server.Guid;

            if (bestServer == 0) {
                bestServer = [serverPlayerCount, serverId];
            };

            if (serverPlayerCount < bestServer[0]) {
                bestServer = [serverPlayerCount, serverId];
            }

            if (e == gameInstances.Collection.length) {
                if (bestServer[0].between(maxPlayers - maxPlayers, Math.round(maxPlayers / 1.5)) && server.UserCanJoin) {
                    try {
                        window.Roblox.GameLauncher.joinGameInstance(parseInt(gameIdString), bestServer[1]);
                    } catch (err) {
                        window.alert(err);
                    }
                } else {
                    SI -= 10;
                    fetch('https://web.roblox.com/games/getgameinstancesjson?placeId=' + gameIdString + '&startindex=' + SI.toString())
                        .then(res => res.json())
                        .then((out) => {
                            join(out);
                        }).catch(err => window.alert(err));
                }
                console.log(bestServer);
            }
        }
    }

    function round(num) {
        SI = Math.floor(num / 10) * 10;
        fetch('https://web.roblox.com/games/getgameinstancesjson?placeId=' + gameIdString + '&startindex=' + SI.toString())
            .then(res => res.json())
            .then((out) => {
                if (out.Collection.length > 0) {
                    join(out);
                } else {
                    round(num - 5);
                }
            }).catch(err => window.alert(err));
    }

    function main() {
        // console.log(gameIdString)
        window.alert("Joining..");
        fetch('https://web.roblox.com/games/getgameinstancesjson?placeId=' + gameIdString + '&startindex=0')
            .then(res => res.json())
            .then((out) => {
                round(out.TotalCollectionSize);
            }).catch(err => window.alert(err));
    }

    let button = document.createElement("span");
    button.classList.add("btn-secondary-md");
    button.innerText = "Join server with least amount of players";
    button.onclick = main;
    document.getElementById("game-instances").prepend(button);
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。