Join Blocked Player

Join Roblox players who are blocking you.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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