Steam游戏详细信息

在Steam商店页面添加一个“查看详细信息”按钮,点击后在新标签页中跳转到SteamDB页面

  1. // ==UserScript==
  2. // @name Steam游戏详细信息
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 在Steam商店页面添加一个“查看详细信息”按钮,点击后在新标签页中跳转到SteamDB页面
  6. // @author myncdw
  7. // @match https://store.steampowered.com/app/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建“查看详细信息”按钮的函数
  16. function createJumpButton() {
  17. const button = document.createElement('a');
  18. button.className = 'btn_green_steamui btn_medium';
  19. button.style.float = 'right'; // 让按钮参与浮动布局
  20. button.style.display = 'inline-block'; // 确保按钮与其他按钮在同一行显示
  21. button.style.verticalAlign = 'middle'; // 调整垂直对齐以防止错位
  22. button.target = '_blank'; // 设置为在新标签页中打开
  23.  
  24. const currentUrl = window.location.href;
  25. const appIdMatch = currentUrl.match(/\/app\/(\d+)/);
  26. if (appIdMatch) {
  27. const appId = appIdMatch[1];
  28. const steamDbUrl = `https://steamdb.info/app/${appId}`;
  29. button.href = steamDbUrl; // 将按钮的href设置为SteamDB的URL
  30. }
  31.  
  32. const span = document.createElement('span');
  33. span.textContent = '查看详细信息';
  34. button.appendChild(span);
  35.  
  36. // 尝试找到“添加至购物车”按钮
  37. const addToCartDiv = document.querySelector('.btn_addtocart');
  38. if (addToCartDiv) {
  39. // 确保按钮在 addToCartDiv 的右侧
  40. addToCartDiv.parentNode.insertBefore(button, addToCartDiv.nextSibling);
  41. } else {
  42. console.error('未找到“添加至购物车”按钮');
  43. }
  44. }
  45.  
  46. // 使用MutationObserver在页面加载完成后创建按钮
  47. // const observer = new MutationObserver((mutations, obs) => {
  48. // if (document.querySelector('.btn_addtocart')) {
  49. // createJumpButton();
  50. // obs.disconnect();
  51. // }
  52. // });
  53.  
  54. // observer.observe(document.body, {
  55. // childList: true,
  56. // subtree: true
  57. // });
  58.  
  59. window.addEventListener('load', () => {
  60. createJumpButton();
  61. });
  62. })();

QingJ © 2025

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