Remove Demos From Steam While Browsing

Remove demo panels only if they contain the "Free Demo" indicator

  1. // ==UserScript==
  2. // @name Remove Demos From Steam While Browsing
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Remove demo panels only if they contain the "Free Demo" indicator
  6. // @match https://store.steampowered.com/*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. function removeFreeDemoPanels() {
  14. // Find all candidate demo panel containers.
  15. const panels = document.querySelectorAll('div._1_P15GG6AKyF_NMX2j4-Mu.Panel.Focusable');
  16. panels.forEach(panel => {
  17. // Look for a child element with the Free Demo indicator.
  18. const freeDemoIndicator = panel.querySelector('div._3j4dI1yA7cRfCvK8h406OB');
  19. if (freeDemoIndicator && freeDemoIndicator.textContent.trim() === "Free Demo") {
  20. panel.remove();
  21. console.log("Removed Free Demo panel:", panel);
  22. }
  23. });
  24. }
  25.  
  26. // Run on initial page load.
  27. window.addEventListener('load', removeFreeDemoPanels);
  28.  
  29. // Observe DOM mutations in case panels are added dynamically.
  30. const observer = new MutationObserver(mutations => {
  31. for (const mutation of mutations) {
  32. if (mutation.addedNodes.length > 0) {
  33. removeFreeDemoPanels();
  34. }
  35. }
  36. });
  37.  
  38. observer.observe(document.body, { childList: true, subtree: true });
  39. })();