Steam Community - All Workshop Items Subscriber

Subscribes or unsubscribes to all workshop items from a particular AppID

目前為 2016-06-20 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Steam Community - All Workshop Items Subscriber
// @namespace    Royalgamer06
// @version      0.3
// @description  Subscribes or unsubscribes to all workshop items from a particular AppID
// @author       Royalgamer06
// @include      *://steamcommunity.com/workshop/browse/?appid=*
// @grant        none
// ==/UserScript==

function subAll(method) {
    var modal = ShowBlockingWaitDialog("Executing…", "Please wait until all requests finish. \nThe page will automatically reload when it is finished.");
    var appid = location.href.split("appid=")[1].split("&")[0];
    var sessionid = g_sessionID;
    var pageinfo = jQuery(".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;
    var 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;
        }
        jQuery.get(url, function(data) {
            var s = jQuery(data).find(".workshopItemPreviewHolder");
            for (var i = 0; i < s.length; i++) {
                var wsid = s[i].getAttribute("id").replace("sharedfile_","");
                jQuery.post("http://steamcommunity.com/sharedfiles/" + method, { id: wsid, appid: appid, sessionid: sessionid }).always(function() {
                    loaded++;
                    modal.Dismiss();
                    if( loaded >= total ) {
                        location.reload();
                    } else {
                        modal = ShowBlockingWaitDialog( 'Executing…', 'Loaded <b>' + loaded + '</b>/' + total + '.' );
                    }
                });
            }
        });
    }
}

jQuery(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>';
    jQuery(".panel:first").prepend(html);
    document.getElementById("suball").onclick = function() { subAll("subscribe"); };
    document.getElementById("unsuball").onclick = function() { subAll("unsubscribe"); };
});