SteamDB Piracy Redirect Buttons

Adds redirect buttons to popular piracy sites on SteamDB.info app pages.

  1. // ==UserScript==
  2. // @name SteamDB Piracy Redirect Buttons
  3. // @namespace https://steamdb.info/
  4. // @version 1.2.0
  5. // @description Adds redirect buttons to popular piracy sites on SteamDB.info app pages.
  6. // @author nightsman
  7. // @license GNU GPLv3
  8. // @match https://steamdb.info/app/*/
  9. // @grant none
  10. // @homepageURL https://github.com/yourusername/steamdb-piracy-redirect
  11. // @supportURL https://github.com/yourusername/steamdb-piracy-redirect/issues
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Define the buttons to be added
  18. const redirectButtons = [
  19. {
  20. label: 'SteamRIP',
  21. urlPrefix: 'https://steamrip.com/?s=',
  22. },
  23. {
  24. label: 'GOG Games',
  25. urlPrefix: 'https://gog-games.to/?search=',
  26. },
  27. {
  28. label: 'AnkerGames',
  29. urlPrefix: 'https://ankergames.net/search/',
  30. },
  31. {
  32. label: 'Fitgirl Repacks',
  33. urlPrefix: 'https://fitgirl-repacks.site/?s=',
  34. },
  35. {
  36. label: 'Dodi Repacks',
  37. urlPrefix: 'https://dodi-repacks.site/?s=',
  38. },
  39. ];
  40.  
  41. // Function to add the buttons to the page
  42. function addRedirectButtons() {
  43. // Select the game title element and the navigation links container
  44. const titleElement = document.querySelector('h1');
  45. const navLinks = document.querySelector('nav.app-links');
  46.  
  47. // If either element is not found, exit the function
  48. if (!titleElement || !navLinks) {
  49. console.error('SteamDB Piracy Redirect: Could not find required elements.');
  50. return;
  51. }
  52.  
  53. // Extract and clean the game title
  54. let gameTitle = titleElement.textContent.trim();
  55. // Remove non-ASCII characters from the game title for better URL compatibility
  56. gameTitle = gameTitle.replace(/[^\x00-\x7F]/g, '');
  57.  
  58. // Define the CSS for the new buttons
  59. const buttonStyle = `
  60. .app-links > a.dynamic-button {
  61. display: inline-block;
  62. cursor: pointer;
  63. color: #67c1f5;
  64. background: #273b4b;
  65. border: 1px solid rgb(255 255 255 / 10%);
  66. padding: 0 10px;
  67. font-size: 15px;
  68. line-height: 30px;
  69. border-radius: 6px;
  70. margin-right: 5px; /* Added a small margin between buttons */
  71. text-decoration: none;
  72. transition: background-color 0.2s ease-in-out; /* Added transition for hover effect */
  73. }
  74. .app-links > a.dynamic-button:hover {
  75. background-color: #3a5b75; /* Darken background on hover */
  76. color: var(--link-color-hover, #0095ff);
  77. }
  78. .app-links > a:last-child {
  79. margin-right: 0;
  80. }
  81. `;
  82.  
  83. // Create and append the style element to the head
  84. const styleElement = document.createElement('style');
  85. styleElement.textContent = buttonStyle;
  86. document.head.appendChild(styleElement);
  87.  
  88. // Create and append each redirect button
  89. redirectButtons.forEach(({ label, urlPrefix, urlSuffix = '' }) => {
  90. const btn = document.createElement('a');
  91. // Encode the game title for use in URLs
  92. btn.href = urlPrefix + encodeURIComponent(gameTitle) + urlSuffix;
  93. btn.textContent = label;
  94. btn.target = '_blank'; // Open link in a new tab
  95. btn.className = 'dynamic-button';
  96. navLinks.appendChild(btn);
  97. });
  98. }
  99.  
  100. // Wait for the window to fully load before adding buttons
  101. window.addEventListener('load', addRedirectButtons);
  102.  
  103. })();