Skip to content

Instantly share code, notes, and snippets.

@Anach
Created December 29, 2025 02:49
Show Gist options
  • Select an option

  • Save Anach/2173c6657710b41eb444fe2d01a2f71a to your computer and use it in GitHub Desktop.

Select an option

Save Anach/2173c6657710b41eb444fe2d01a2f71a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Steam Workshop SteamCMD Button
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Button to copy download link in SteamCMD format.
// @author Anach
// @match https://steamcommunity.com/sharedfiles/filedetails/?id=*
// @match https://steamcommunity.com/workshop/filedetails/?id=*
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
function getIDs() {
const modID = new URLSearchParams(window.location.search).get('id');
let appID = null;
const storeLink = document.querySelector('.workshopItemTitle a[href*="/app/"]')?.href
|| document.querySelector('a[href*="/app/"]')?.href;
if (storeLink) {
const match = storeLink.match(/\/app\/(\d+)/);
if (match) appID = match[1];
}
return { appID, modID };
}
function showToast(message, type='success') {
const toast = document.createElement('div');
toast.textContent = message;
toast.style.position = 'fixed';
toast.style.bottom = '14px';
toast.style.right = '14px';
toast.style.padding = '8px 14px';
toast.style.fontFamily = '"Motiva Sans", Arial, Helvetica, sans-serif';
toast.style.fontSize = '13px';
toast.style.borderRadius = '6px';
toast.style.zIndex = '99999';
toast.style.opacity = '0';
toast.style.lineHeight = '1.2';
toast.style.transition = 'opacity 0.5s ease';
toast.style.backdropFilter = 'blur(4px)';
toast.style.webkitBackdropFilter = 'blur(4px)';
toast.style.background = 'rgba(23,26,33,0.85)';
toast.style.boxShadow = '0 3px 10px rgba(0,0,0,0.5)';
if (type === 'warning') {
toast.style.color = '#ffd000';
toast.style.border = '1px solid rgba(255,100,0,0.5)';
toast.style.background = 'rgba(23,26,33,0.92)';
toast.style.boxShadow = '0 0 12px rgba(255,120,0,0.4)';
} else {
toast.style.color = '#66ffcc';
toast.style.border = '1px solid rgba(102,255,204,0.22)';
}
document.body.appendChild(toast);
requestAnimationFrame(()=>toast.style.opacity='1');
setTimeout(()=>toast.style.opacity='0', 1200);
setTimeout(()=>toast.remove(), 1700);
}
function insertButton() {
const subscribe = document.querySelector('#SubscribeItemBtn');
if (!subscribe) return;
if (document.querySelector('.workshopSteamCMDButton')) return;
const ids = getIDs();
const btn = document.createElement('div');
btn.className = subscribe.className + ' workshopSteamCMDButton';
btn.style.fontFamily = '"Motiva Sans", Arial, Helvetica, sans-serif';
// Hover effect (slight darken)
btn.addEventListener('mouseenter', () => btn.style.filter='brightness(0.92)');
btn.addEventListener('mouseleave', () => btn.style.filter='brightness(1)');
// Icon + label
btn.innerHTML = `
<span style="display:flex;align-items:center;gap:13px;padding-left:6px;padding-right:23px;">
<span style="font-size:14px;">📋</span>
<span>SteamCMD</span>
</span>
`;
btn.addEventListener('click', () => {
const valid = ids.appID && ids.modID;
const cmd = valid
? `workshop_download_item ${ids.appID} ${ids.modID}`
: `⚠ Missing IDs — AppID: ${ids.appID || 'NOT FOUND'} | ModID: ${ids.modID || 'NOT FOUND'}`;
GM_setClipboard(cmd);
if (!valid) showToast('⚠ Missing AppID or ModID', 'warning');
else showToast('SteamCMD copied!', 'success');
});
subscribe.parentElement.appendChild(btn);
console.log('[SteamCMD Button] ➕ Injected SteamCMD button');
}
const observer = new MutationObserver(insertButton);
observer.observe(document.body, { childList: true, subtree: true });
window.addEventListener('load', insertButton);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment