Greasy Fork

Greasy Fork is available in English.

Steam Downloader

Downloads anything from the steam workshop

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Steam Downloader
// @version        0.2
// @description    Downloads anything from the steam workshop
// @author         cpilton
// @include        *steamcommunity.com/sharedfiles/filedetails/?id=*
// @include        *steamcommunity.com/workshop/filedetails/?id=*
// @grant          GM_xmlhttpRequest
// @namespace      http://greasyfork.icu/users/420396
// ==/UserScript==

var appID;

(function() {
    'use strict';

    addButton();
    getAppID();
})();

function addButton() {
    var div = document.createElement("div");
    div.classList.add("workshopItemControlCtn");
    div.innerHTML = '<span id="downloadButton" style="margin-top:6px" class="general_btn share tooltip"><span>Download</span></span>';
    div.onclick = function() {
        download();
    }

    var element = document.getElementById("action_wait");
    element.parentNode.insertBefore(div, element);
}

function getAppID() {
    var element = document.getElementById("ig_bottom").getElementsByClassName("btnv6_blue_hoverfade btn_medium")[0];
    appID = element.getAttribute("data-appid");
}

function download() {
    getDownloadLink(getID());
}

function getID() {
    var url_string = window.location.href;
    var url = new URL(url_string);
    var id = url.searchParams.get("id");
    return id;
}

function getDownloadLink(id) {
    var request="item="+id+"&app="+appID;
    GM_xmlhttpRequest({
        method: "POST",
        url: "http://steamworkshop.download/online/steamonline.php",
        data: request,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        onload: function (response) {
            var href = response.responseText.split("'");
            downloadFile(href[1]);
        },
        onerror: function (reponse) {
            //alert('error');
            console.log(reponse);
        }
    });
}

function downloadFile(url) {
    window.location.assign(url);
}