Steam Group Cleaner

批量自定义取消关注Steam组

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Steam Group Cleaner
// @namespace    TypeNANA
// @version      0.2
// @description  批量自定义取消关注Steam组
// @author       TypeNANA
// @match        https://steamcommunity.com/id/*/groups/
// @match        https://steamcommunity.com/profiles/*/groups/
// ==/UserScript==
(function () {
    function delGroups() {
        var checkBoxs = document.getElementsByClassName("groupCheck");
        var list = [];
        for (var i in checkBoxs) {
            if (checkBoxs[i].checked) {
                list.push(checkBoxs[i].id);
            }
        }
        webRequest(list, 0);
    }
    var modal;

    function webRequest(packages, index) {
        if (index >= packages.length) {
            location.reload();
            return;
        };
        if (packages[index] == undefined) {
            webRequest(packages, index + 1);
            return;
        }
        modal = ShowBlockingWaitDialog('请求中', '退出选定组中,已完成' + (index) + "/" + packages.length);
        var url = window.location.href.replace("/groups/", "/friends/action");
        jQuery.post(url, {
            action: "leave_group",
            ajax: "1",
            sessionid: g_sessionID,
            steamid: g_steamID,
            "steamids[]": packages[index],
        }).done(function (res) {
            modal.Dismiss();
            webRequest(packages, index + 1);
        });
    }

    function checkAll() {
        var checkBoxs = document.getElementsByClassName("groupCheck");
        var flag = document.getElementById("checkAll").checked;
        for (var i in checkBoxs) {
            checkBoxs[i].checked = flag;
        }
    }

    function SetPage() {
        var reg = /ConfirmLeaveGroup\(\s*'(\d+)\s*'\s*/;
        var rows = document.getElementsByClassName("group_block");
        for (var i = 0, l = rows.length; i < l; i++) {
            var groupId = reg.exec(rows[i].innerHTML)[1];
            rows[i].innerHTML = '<input class="groupCheck" id="' + groupId + '" type="checkbox"  style="position:absolute;top:0;right:0;height:20px;width:20px"/>' + rows[i].innerHTML;
        }
        var page_content = document.getElementById("search_results");
        page_content.innerHTML += '<div style="text-align: right;width: 100%;margin-top:20px"><input id="checkAll" type="checkbox" style="vertical-align:middle;height:20px;width:20px;"><label for="checkAll" style="margin-right:15px;">全选</label><a id="delGroups" class="btn_darkblue_white_innerfade" style="padding: 0 15px;font-size: 15px;line-height: 30px;">退出选定组</a></div>';

        document.getElementById("delGroups").onclick = function () {
            delGroups();
        };
        document.getElementById("checkAll").onchange = function () {
            checkAll();
        };
    }
    SetPage();
})();