Adds a open in steam button to workshop links.
当前为
// ==UserScript==
// @name Steam Workshop Open in Steam
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds a open in steam button to workshop links.
// @match https://steamcommunity.com/sharedfiles/filedetails/?id=*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function addOpenInSteamButton() {
var workshopId = new URLSearchParams(window.location.search).get('id');
if (workshopId) {
var button = document.createElement('a');
button.textContent = 'Open in Steam';
button.href = 'steam://url/CommunityFilePage/' + workshopId;
button.style.cssText = 'display: inline-block; padding: 10px 15px; background-color: #1b2838; color: white; text-decoration: none; border-radius: 3px; margin: 10px 0;';
var targetElement = document.querySelector('.workshopItemTitle');
if (targetElement) {
targetElement.parentNode.insertBefore(button, targetElement.nextSibling);
}
}
}
// Run the function when the page is fully loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', addOpenInSteamButton);
} else {
addOpenInSteamButton();
}
})();