Roblox Smart Server Join

Join Roblox servers intelligently based on server size, including private servers with debugging logs

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Roblox Smart Server Join
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Join Roblox servers intelligently based on server size, including private servers with debugging logs
// @author       Kanako
// @match        *://www.roblox.com/*
// @grant        none
// @license      Apache License 2.0
// ==/UserScript==

(function() {
    'use strict';

    // Function to join a public server using the protocol URL
    function joinPublicServer(placeId, jobId) {
        const protocolUrl = `roblox://experiences/start?placeId=${placeId}&gameInstanceId=${jobId}`;
        console.log(`Joining public server with URL: ${protocolUrl}`);
        window.location.href = protocolUrl;
    }

    // Function to join a private server using the protocol URL
    function joinPrivateServer(placeId, linkCode) {
        const protocolUrl = `roblox://placeid=${placeId}&linkcode=${linkCode}`;
        console.log(`Joining private server with URL: ${protocolUrl}`);
        window.location.href = protocolUrl;
    }

    // Extract the placeId and linkCode from the URL
    function extractParamsFromUrl(url) {
        const regex = /\/games\/(\d+)\/[^?]+\?privateServerLinkCode=(\d+)/;
        const match = url.match(regex);
        if (match && match.length === 3) {
            console.log(`Extracted placeId: ${match[1]}, linkCode: ${match[2]}`);
            return { placeId: match[1], linkCode: match[2] };
        } else {
            console.error('Could not extract placeId and linkCode from URL');
            return null;
        }
    }

    // Disable default join behavior for private servers
    function disableDefaultJoin() {
        window.addEventListener('click', function(event) {
            const element = event.target;
            if (element.tagName === 'A' && element.href && element.href.startsWith('https://www.roblox.com/games/') &&
                element.href.includes('privateServerLinkCode')) {
                event.preventDefault();
            }
        });
    }

    // Replace current page with a blank page
    function replaceWithBlankPage() {
        const blankPageUrl = 'about:blank';
        console.log('Replacing page with a blank page...');
        window.location.replace(blankPageUrl);
    }

    // Run the setup functions and replace with a blank page immediately
    disableDefaultJoin();
    const params = extractParamsFromUrl(window.location.href);
    if (params) {
        const { placeId, linkCode } = params;
        console.log('Detected private server link.');
        joinPrivateServer(placeId, linkCode);
    } else {
        const playButton = document.querySelector('button[data-testid="play-button"]');
        if (playButton) {
            console.log('Play button detected.');
            playButton.addEventListener('click', async function(e) {
                e.preventDefault();
                console.log('Play button clicked');
                // Add your logic to join a public server here
            });
        }

        // Add logic to handle joining public servers here
        console.log('Searching for public server join button.');
    }
    replaceWithBlankPage(); // Replace with a blank page after setup
})();