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.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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