Join all groups on a profile

Join all of someone's steam groups quickly

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Join all groups on a profile
// @namespace    http://tampermonkey.net/
// @version      0.1.6
// @description  Join all of someone's steam groups quickly
// @author       hoocs
// @match        *://steamcommunity.com/id/*
// @match        *://steamcommunity.com/profiles/*
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        none
// @license MIT1
// ==/UserScript==

function JoinProfilesGroups() {
    let steamID = g_rgProfileData?.steamid || "";
    let sessionID = g_sessionID || "";

    if (!steamID || !sessionID) {
        console.log("Could not retrieve steamID or sessionID.");
        return;
    }

    $.ajax({
        url: 'https://steamcommunity.com/profiles/' + steamID + '/?xml=1',
        type: 'GET',
        dataType: 'xml'
    }).done(function(xml) {
        let groupIDs = [];
        $(xml).find('groupID64').each(function() {
            groupIDs.push($(this).text());
        });

        let joinRequests = groupIDs.map(groupID => {
            return $.ajax({
                url: 'https://steamcommunity.com/gid/' + groupID,
                type: 'POST',
                dataType: 'json',
                data: { action: 'join', sessionID: sessionID },
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            }).done(function(data) {
                console.log('Joined Group:', groupID);
            }).fail(function() {
                console.log('Error joining group:', groupID);
            });
        });

        Promise.all(joinRequests).then(() => {
            console.log('All group join requests processed.');
        }).catch(() => {
            console.log('Some group join requests failed.');
        });
    }).fail(function() {
        console.log('Failed to retrieve group list. Check if the profile is public.');
    });
}

JoinProfilesGroups();