One-Click Subscribe to all steam workshop items

Subscribe to all items shown.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         One-Click Subscribe to all steam workshop items
// @namespace    https://github.com/joex92/One-Click-Subscribe-to-all-Steam-workshop-items
// @version      2.4
// @description  Subscribe to all items shown.
// @author       JoeX92
// @match        https://steamcommunity.com/workshop/browse/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=steamcommunity.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    window.onload = ()=>{
        const btn = document.createElement("span");
        btn.setAttribute("data-panel","{"focusable":true,"clickOnActivate":true}");
        btn.setAttribute("role","button");
        btn.className = "general_btn createCollection";
        btn.textContent = ( document.querySelectorAll(".general_btn.subscribe:not(.toggled)").length ) ? "Subscribe to all" : "Unsubscribe to all";
        btn.onclick = async (e)=>{
            const unsubscribeditems = document.querySelectorAll(".general_btn.subscribe:not(.toggled)");
            if ( unsubscribeditems.length ) {
                btn.textContent = "Subscribing...";
                btn.style.pointerEvents = 'none';
                unsubscribeditems.forEach( async (i,n)=>{
                    await i.onclick();
                    console.log(`${n.toString().padStart(2,0)}) Subscribed to item id: ${i.id.match(/(\d+)/)[0]}`);
                });
                btn.textContent = "Unsubscribe to all";
                btn.style.pointerEvents = '';
            } else {
                const subscribeditems = document.querySelectorAll(".general_btn.subscribe.toggled");
                btn.textContent = "Unsubscribing...";
                btn.style.pointerEvents = 'none';
                subscribeditems.forEach( async (i,n)=>{
                    await i.onclick();
                    console.log(`${n.toString().padStart(2,0)}) Unsubscribed to item id: ${i.id.match(/(\d+)/)[0]}`);
                });
                btn.textContent = "Subscribe to all";
                btn.style.pointerEvents = '';
            }
        };
        const rsection = document.querySelector(".rightSectionHolder>.rightDetailsBlock")
        if ( rsection ) rsection.insertAdjacentElement("afterbegin",btn);
        else document.querySelector('.right_column>.panel').insertAdjacentElement("afterbegin",btn);
    };

    // Your code here...
})();