Steamworkshop downloader

Downloads Steam Workshop items that really works, replacing the deprecated or free space left from steamworkshop.download

目前为 2023-11-07 提交的版本。查看 最新版本

// ==UserScript==
// @name        Steamworkshop downloader
// @namespace   Violentmonkey Scripts
// @match        *://steamcommunity.com/workshop/filedetails/?id=*
// @match        *://steamcommunity.com/sharedfiles/filedetails/?id=*
// @version     1.0
// @author      https://github.com/InsightiousCoven
// @include     *steamcommunity.com/sharedfiles/filedetails/?id=*
// @include     *steamcommunity.com/workshop/filedetails/?id=*
// @grant       GM_xmlhttpRequest
// @icon        https://www.google.com/s2/favicons?sz=64&domain=steamcommunity.com
// @description Downloads Steam Workshop items that really works, replacing the deprecated or free space left from steamworkshop.download
// @license     GPL-3.0
// ==/UserScript==

var patt = new RegExp("[0-9]{2,15}");
var id = patt.exec(document.URL)[0];
var baseUrl = "https://steamcommunity.com/sharedfiles/filedetails/?id="

if (document.URL.indexOf("steamcommunity.com") != -1) {
    if (document.URL.indexOf("workshop") != -1 || document.URL.indexOf("filedetails") != -1) {
        if(!id)
          alert("CANNOT GET ID!")

        addMeta();
        addWorkshopBtn(id);
    }
}

function addMeta() {
  var meta = document.querySelector('meta[http-equiv="Content-Security-Policy"]');
  var allowedUrls = "https://api.ggntw.com https://api.ggntw.com/steam.request"

  if (meta) {
    meta.content += " " + allowedUrls;
  } else {
    meta = document.createElement('meta');
    meta.httpEquiv = "Content-Security-Policy";
    meta.content = "connect-src 'self' " + allowedUrls;
    document.getElementsByTagName('head')[0].appendChild(meta);
  }
}

function SBS_NW(url) {
    console.log("DOWNLOADING: "+url)
    GM_xmlhttpRequest({
        anonymous: true,
        method: "POST",
        url: "https://api.ggntw.com/steam.request",
        data: JSON.stringify({url}),
        headers: {
            "Content-Type": "application/json",
            "User-Agent":"insomnia/2023.5.8"
        },
        onprogress: () => {},
        responseType: "json",
        onload: response => {
          console.log("success!", {response})
          window.open(response.response.url,"_blank")
        },
        onerror: reponse => {
            alert('error')
        }
    });
}

function addWorkshopBtn(id) {
    var element = document.getElementById("AddToCollectionBtn");
    var button = document.createElement('span');
    button.setAttribute('class', 'general_btn share tooltip');

    button.innerHTML = '<span id="SUBS_TO_ITEM"><span>Download this ⬇️</span></span>';
    button.onclick = function() {
        SBS_NW(baseUrl+id);
    }

    if (element.nextSibling) {
        element.parentNode.insertBefore(button, element.nextSibling);
    } else {
        element.parentNode.appendChild(button);
    }
    document.querySelectorAll(".game_area_purchase_game")[0].getElementsByTagName('h1')[0].setAttribute('style', 'width: 300px;');
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址