Join Blocked Player

Join Roblox players who are blocking you.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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 });
    }
})();