Steam Filter Games by Geforce NOW Availability/Compatibility

Adds a button to Steam Community games list pages (https://steamcommunity.com/id/<user_id>/games/?tab=all) that will filter out all games that are not supported by Geforce NOW, leaving only supported games visible.

  1. // ==UserScript==
  2. // @name Steam Filter Games by Geforce NOW Availability/Compatibility
  3. // @namespace driver8.net
  4. // @version 0.1.3
  5. // @description Adds a button to Steam Community games list pages (https://steamcommunity.com/id/<user_id>/games/?tab=all) that will filter out all games that are not supported by Geforce NOW, leaving only supported games visible.
  6. // @author driver8
  7. // @match *://*.steamcommunity.com/id/*/games*
  8. // @match *://*.steamcommunity.com/my/games*
  9. // @match *://*.steamcommunity.com/profiles/*/games*
  10. // @grant GM.xmlHttpRequest
  11. // @connect static.nvidiagrid.net
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. console.log('hi gfn filter');
  18.  
  19. let supportedGames = [],
  20. notSupportedGames = [],
  21. insAt = document.querySelector('#mainContents > .sectionTabs'),
  22. newDiv = document.createElement('div');
  23. var gfnSteamIds = {};
  24.  
  25. newDiv.innerHTML = `<a class="sectionTab "><span>Geforce NOW Compatible</span></a>`;
  26. let newA = newDiv.firstElementChild;
  27. newA.onclick = () => {
  28. checkJSON();
  29. newA.innerHTML = '<span>Filtering...</span>';
  30. newA.onclick = null;
  31. };
  32. insAt.appendChild(newA);
  33.  
  34. function filterGames() {
  35. if (!gfnSteamIds) return;
  36. let allGameRows = Array.from(document.querySelectorAll('.gameListRow'));
  37. for (let row of allGameRows) {
  38. let m = row.id.match(/game_(\d+)/); // steam ID
  39. let isSupported = m && gfnSteamIds.hasOwnProperty(m[1]);
  40. (isSupported ? supportedGames : notSupportedGames).push(row);
  41. }
  42. for (let div of notSupportedGames) {
  43. div.style.display = 'none';
  44. }
  45. window.dispatchEvent(new Event('resize')); // hacky fix for images not lazy-loading
  46. console.log('Supported games', supportedGames);
  47. newA.innerHTML = `<span>${supportedGames.length} games supported by Geforce NOW</span>`;
  48. }
  49.  
  50. function checkJSON() {
  51. GM.xmlHttpRequest({
  52. method: "GET",
  53. url: "https://static.nvidiagrid.net/supported-public-game-list/gfnpc.json",
  54. reponseType: "JSON",
  55. onload: function(response) {
  56. let gfnJSON = JSON.parse(response.responseText);
  57. console.log('json', gfnJSON);
  58. for (let game of gfnJSON) {
  59. let m = game.steamUrl.match(/\/(\d+)$/i);
  60. if (m) {
  61. gfnSteamIds[m[1]] = game;
  62. }
  63. }
  64. filterGames();
  65. }
  66. });
  67. }
  68. })();