GOG - Hide DLCs by default

Hide DLCs in the store page by default. Doesn't work on some links

  1. // ==UserScript==
  2. // @name GOG - Hide DLCs by default
  3. // @namespace amekusa.gog-hide-dlcs
  4. // @author amekusa
  5. // @version 1.0.1
  6. // @description Hide DLCs in the store page by default. Doesn't work on some links
  7. // @match https://www.gog.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT
  11. // @homepage https://github.com/amekusa/monkeyscripts
  12. // ==/UserScript==
  13.  
  14. (function (doc) {
  15. // url params to add to the store links
  16. let params = 'hideDLCs=true';
  17. // params += '&discounted=true'; // option: Show only discounted
  18. // params += '&hideOwned=true'; // option: Hide all owned products
  19.  
  20. let addParams = link => {
  21. let href = link.getAttribute('href');
  22. link.setAttribute('href', href + (href.includes('?') ? '&' : '?') + params);
  23. };
  24. let update = () => {
  25. let links = [];
  26. let exclude = `:not([href*="${params}"])`;
  27. links.push(doc.querySelectorAll('a[href$="/games"]' + exclude));
  28. links.push(doc.querySelectorAll('a[href*="/games?"]' + exclude));
  29. links.push(doc.querySelectorAll('a[href*="/games/"]' + exclude));
  30. // links.push(doc.querySelectorAll('a[href*="/promo/"]' + exclude));
  31. for (let i = 0; i < links.length; i++) links[i].forEach(addParams);
  32. };
  33. doc.addEventListener('DOMContentLoaded', update);
  34. doc.addEventListener('scrollend', update);
  35.  
  36. })(document);
  37.  

QingJ © 2025

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