Add "Friends That Play" Button on Steam Gamecards

Adds a "Friends That Play" button after the Store Page button, and removes the apphub_OtherSiteInfo div to avoid issues on Steam gamecards pages.

  1. // ==UserScript==
  2. // @name Add "Friends That Play" Button on Steam Gamecards
  3. // @namespace https://github.com/encumber
  4. // @version 1.3
  5. // @description Adds a "Friends That Play" button after the Store Page button, and removes the apphub_OtherSiteInfo div to avoid issues on Steam gamecards pages.
  6. // @author Nitoned
  7. // @match https://steamcommunity.com/id/*/gamecards/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13. const yourid = "yourid"
  14. const appIdMatch = window.location.pathname.match(/\/gamecards\/(\d+)/);
  15. if (!appIdMatch) return;
  16. const appId = appIdMatch[1];
  17.  
  18. const interval = setInterval(() => {
  19. // Remove any div with the class apphub_OtherSiteInfo
  20. const otherSiteDiv = document.querySelector('div.apphub_OtherSiteInfo');
  21. if (otherSiteDiv) {
  22. otherSiteDiv.remove();
  23. }
  24.  
  25. // Look for the correct Store Page button
  26. const allLinks = document.querySelectorAll('a');
  27. let storePageButton = null;
  28.  
  29. for (const link of allLinks) {
  30. const span = link.querySelector('span');
  31. if (span && span.textContent.trim() === 'Store Page') {
  32. storePageButton = link;
  33. break;
  34. }
  35. }
  36.  
  37. if (storePageButton) {
  38. clearInterval(interval);
  39.  
  40. const newLink = document.createElement('a');
  41. newLink.href = `https://steamcommunity.com/id/${yourid}/friendsthatplay/${appId}`;
  42. newLink.className = storePageButton.className;
  43. newLink.style.marginLeft = '6px';
  44.  
  45. const newSpan = document.createElement('span');
  46. newSpan.className = storePageButton.querySelector('span')?.className || '';
  47. newSpan.textContent = 'Friends That Play';
  48.  
  49. newLink.appendChild(newSpan);
  50. storePageButton.parentNode.insertBefore(newLink, storePageButton.nextSibling);
  51. }
  52. }, 500);
  53. })();