Join Blocked Player

Join Roblox players who are blocking you.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Join Blocked Player
// @namespace    tomohiror.f5.si
// @version      2.2
// @description  Join Roblox players who are blocking you.
// @author       tomohiror
// @license      MIT
// @match        https://www.roblox.com/users/*
// @icon         https://github.com/tomohiror.png
// @connect      presence.roblox.com
// @grant        GM.xmlHttpRequest
// @grant        unsafeWindow
// @run-at       document-end
// @noframes
// ==/UserScript==

const ALT_ROBLOSECURITY = "<your alt .ROBLOSECURITY here>";

(async () => {
    'use strict';

    const targetUserId = Number.parseInt(location.pathname.split("/")[2], 10);
    if (targetUserId == unsafeWindow.Roblox.CurrentUser.userId) {
        return;
    }

    const mainPromise = unsafeWindow.RobloxPresence.getPresenceProvider().getPresences([targetUserId]);
    const response = await GM.xmlHttpRequest({
        method: "POST",
        url: "https://presence.roblox.com/v1/presence/users",
        data: JSON.stringify({ userIds: [targetUserId] }),
        cookie: ".ROBLOSECURITY=" + ALT_ROBLOSECURITY,
        anonymous: true,
        responseType: "json"
    });
    console.log("JBP fetch", response);
    if (!(200 <= response.status && response.status <= 299)) {
        console.error("JBP fetch fail");
        return;
    }
    const altPresence = response.response.userPresences[0];

    (async () => {
        const mainPresence = (await mainPromise)[0];
        if (altPresence.userPresenceType > mainPresence.userPresenceType) {
            console.log("JBP set status");
            const e = new CustomEvent("Roblox.Presence.Update",
                { detail: new Map().set(targetUserId, altPresence) });
            document.dispatchEvent(e);
        }
    })();

    if (!(altPresence.placeId && altPresence.gameId)) {
        return;
    }
    for (const container of document.getElementsByClassName("button-container")) {
        const addJoin = (_record, observer) => {
            if (!container.nextElementSibling ||
                container.querySelector("#user-profile-header-JoinExperience, #user-profile-header-JoinBlocked")) {
                return;
            }
            observer?.disconnect();

            console.log("JBP add join");
            const btn = document.createElement("button");
            btn.style.width = "100%";
            btn.classList.add("btn-primary-md", "focus-visible:outline-focus");
            btn.id = "user-profile-header-JoinBlocked";
            btn.innerText = "Join Blocked Player";
            btn.addEventListener("click", () => {
                unsafeWindow.Roblox.GameLauncher.joinGameInstance(altPresence.placeId, altPresence.gameId);
            });
            container.insertBefore(btn, container.firstElementChild);
        };
        addJoin();
        new MutationObserver(addJoin).observe(container.parentElement, { childList: true });
    }
})();