Skip to content

Instantly share code, notes, and snippets.

@elboletaire
Created August 10, 2020 00:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elboletaire/e9654139cbd20ee9873e3e0360c0a2f6 to your computer and use it in GitHub Desktop.
Save elboletaire/e9654139cbd20ee9873e3e0360c0a2f6 to your computer and use it in GitHub Desktop.
Steam Workshop download button User Script
// ==UserScript==
// @name Steam Workshop Downloader
// @version 0.1
// @description Downloads steam workshop items using steamworkshopdownloader api
// @author El Boletaire
// @include *steamcommunity.com/sharedfiles/filedetails/?*id=*
// @include *steamcommunity.com/workshop/filedetails/?*id=*
// @grant GM_xmlhttpRequest
// @namespace https://github.com/elboletaire
// ==/UserScript==
(function() {
'use strict'
addButton()
})();
function post(url, data) {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: 'POST',
url: url,
data: data,
headers: {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': 'https://steamworkshopdownloader.io/',
},
onload: resolve,
})
})
}
function downloadButton(text) {
return `<span>${text}</span>`
}
function addButton() {
const a = document.createElement('a')
a.classList.add('btn_darkblue_white_innerfade')
a.classList.add('btn_border_2px')
a.classList.add('btn_medium')
a.id = 'worshop-download-btn'
a.innerHTML = downloadButton('Download')
a.onclick = () => {
a.innerHTML = downloadButton('Downloading...')
download(getFileID(),a)
}
const element = document.getElementById('SubscribeItemBtn')
element.style.float = 'left'
element.style.width = '100%'
a.style.float = 'left'
a.style.width = '100%'
const [title] = document.querySelectorAll('.game_area_purchase_game h1')
title.style.width = '900px'
element.parentNode.insertBefore(a, element.nextSibling);
}
function getFileID() {
const url_string = window.location.href
const url = new URL(url_string)
const id = url.searchParams.get('id')
return id
}
let str = 'retrieving'
function statusPost(uuid) {
post('https://api.steamworkshopdownloader.io/api/download/status', JSON.stringify({uuids: [uuid]})).then((res) => {
JSON.parse(res.responseText, (key, value) => {
if (key === 'status' && value === 'prepared') {
str = value
}
})
})
return str
}
function downloadRequestData(itemId) {
return JSON.stringify({
publishedFileId: parseInt(itemId, 10),
collectionId: null,
extract: true,
hidden: true,
direct: false,
})
}
function download(itemId) {
post('https://api.steamworkshopdownloader.io/api/download/request', downloadRequestData(itemId)).then((res) => {
const [,,,uuid] = res.responseText.split('\"')
const request = `https://api.steamworkshopdownloader.io/api/download/transmit?uuid=${uuid}`
const timer = () => {
if (statusPost(uuid) === 'prepared') {
document.getElementById('worshop-download-btn').innerHTML = downloadButton('Download')
const element = document.createElement('a')
element.href = request
document.body.appendChild(element)
element.click()
element.remove()
return
}
setTimeout(timer, 250)
}
timer()
})
}
@elboletaire
Copy link
Author

It doesnt work currently, the button appears, you click it and nothing happens.

Can you also allow batch downloads (where you can download a collection)?

The API used by this script (from steamworkshopdownloader.io) stopped working a long time ago and I have not been able to find a new one.

@AKASGaming
Copy link

If you own Wallpaper Engine, you can use SteamCMD, idk if that helps or not

@CommunityWorkshop
Copy link

CommunityWorkshop commented Aug 8, 2022

@elboletaire You can try to use our API to download mods from the workshop, visit our Github on: GitHub Link
If you want to intergrate your work with our API and need help or just want to check the progress of the project join our Discord server...

-- GamingNerdLeith#2591 (Community Workshop Downloader) --

@elboletaire
Copy link
Author

@elboletaire You can try to use our API to download mods from the workshop, visit our Github on: GitHub Link If you want to intergrate your work with our API and need help or just want to check the progress of the project join our Discord server...

-- GamingNerdLeith#2591 (Community Workshop Downloader) --

That "github link" points to a non-existant site (which is not github btw).

@elboletaire
Copy link
Author

If you own Wallpaper Engine, you can use SteamCMD, idk if that helps or not

I'm not sure what do you mean by that. You can use SteamCMD anonymously and, as far as I know, you can download anything from the workshops, even not having the game purchased. But I'm not gonna deploy a service to offer downloads. That's why I was using an external API.

@CommunityWorkshop
Copy link

CommunityWorkshop commented Aug 13, 2022

New Link: https://exe.io/GitHub or if that doesnt work then https://github.com/Community-Workshop-Downloader/CommunityWorkshopMain

-- GamingNerdLeith#2591 (Community Workshop Downloader) --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment