Steam Community - All Workshop Items Subscriber

Subscribes or unsubscribes to all workshop items from a particular AppID

当前为 2017-04-30 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Steam Community - All Workshop Items Subscriber
// @namespace    Royalgamer06
// @version      0.4.1
// @description  Subscribes or unsubscribes to all workshop items from a particular AppID
// @author       Royalgamer06
// @include      *://steamcommunity.com/workshop/browse/?appid=*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
// ==/UserScript==

this.$ = this.$ = $.noConflict(true);
$(document).ready(function() {
    var html = '<div class="rightSectionTopTitle">Subscriptions:</div> <div class="rightDetailsBlock"> <div style="position:relative;"> <img class="browseOptionImage" src="http://steamcommunity-a.akamaihd.net/public/images/sharedfiles/filterselect_blue.png?v=1"> <div class="browseOption mostrecent"><a id="suball">Subscribe All</a></div> </div> <div style="position:relative;"> <img class="browseOptionImage" src="http://steamcommunity-a.akamaihd.net/public/images/sharedfiles/filterselect_blue.png?v=1"> <div class="browseOption mostrecent"><a id="unsuball">Unsubscribe All</a></div> </div><hr> </div> </div>';
    $(".panel:first").prepend(html);
    $("#suball").click(function() { subAll("subscribe"); });
    $("#unsuball").click(function() { subAll("unsubscribe"); });
});

function subAll(method) {
    var modal = ShowBlockingWaitDialog("Executing…", "Please wait until all requests finish. \nThe page will automatically reload when it is finished.");
    const appid = location.href.split("appid=")[1].split("&")[0];
    var pageinfo = $(".workshopBrowsePagingInfo").text().replace(",", "");
    var split = pageinfo.split(" ");
    var total = 0;
    for (var i = 0; i < split.length; i++) {
        if (split[i].match(/^[0-9]+$/) !== null) {
            total = parseInt(split[i]);
        }
    }
    var loaded = 1;
    const lastpage = Math.ceil(total/30);
    for (var p = 1; p <= lastpage; p++) {
        var url = location.href;
        if (url.indexOf("p=") > -1) {
            url = url.split("p=")[0] + "p=" + p + url.split("p=")[1].replace(url.split("p=")[1].split("&")[0], "");
        } else {
            url = url + "&p=" + p;
        }
        setTimeout(function() {
            $.get(url, function(data) {
                data = data.replace(/src="[^"]*"/ig, "");
                $(".workshopItemPreviewHolder", data).each(function() {
                    let wsid = $(this).attr("id").replace("sharedfile_","");
                    setTimeout(function() {
                        $.post("//steamcommunity.com/sharedfiles/" + method, { id: wsid, appid: appid, sessionid: g_sessionID }).always(function() {
                            loaded++;
                            modal.Dismiss();
                            if( loaded >= total ) {
                                location.reload();
                            } else {
                                modal = ShowBlockingWaitDialog( 'Executing…', 'Loaded <b>' + loaded + '</b>/' + total + '.' );
                            }
                        });
                    }, 0);
                });
                delete data;
            });
        }, 0);
    }
}