Metacritic: Hide games with no Metascore

When sorting by Newest Releases, games with no Metascore will get hidden. If that ends up being every game on a page, it will skip to the next page

  1. // ==UserScript==
  2. // @name Metacritic: Hide games with no Metascore
  3. // @description When sorting by Newest Releases, games with no Metascore will get hidden. If that ends up being every game on a page, it will skip to the next page
  4. // @version 0.4
  5. // @author mica
  6. // @namespace greasyfork.org/users/12559
  7. // @match https://www.metacritic.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. let url;
  12. const listGames = () => document.querySelectorAll('.c-finderProductCard_meta.g-outer-spacing-top-auto');
  13.  
  14. function hideGames() {
  15. let hidden = 0;
  16. listGames().forEach(elem => {
  17. if (!elem.innerText.includes('Metascore')) {
  18. elem.closest('.c-finderProductCard').remove();
  19. hidden++;
  20. }
  21. })
  22. if (hidden == 24) {
  23. document.querySelector('.c-navigationPagination_item--next > span > span').click();
  24. }
  25. }
  26.  
  27. function checkReady() {
  28. if (listGames().length == 24) {
  29. hideGames();
  30. } else {
  31. setTimeout(checkReady, 100);
  32. }
  33. }
  34.  
  35. setInterval(() => {
  36. if (url != location.href) {
  37. url = location.href;
  38. if (location.pathname.match(/browse\/game.*new/)) {
  39. checkReady();
  40. }
  41. }
  42. }, 100);