Remove Homepage Garbage

Remove Recommended section on the roblox home page!

目前为 2024-08-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Homepage Garbage
  3. // @namespace https://www.roblox.com/home
  4. // @version 2024-08-18
  5. // @description Remove Recommended section on the roblox home page!
  6. // @author CMTG (@callmetreeguy on discord)
  7. // @match https://www.roblox.com/home
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=roblox.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15. function removeRecommendedSection() {
  16. const homePageGameGrid = document.querySelector('div[data-testid="home-page-game-grid"]');
  17. if (homePageGameGrid) {
  18. const header = homePageGameGrid.querySelector('div.container-header > h2');
  19. if (header && header.textContent.trim() === 'Recommended For You') {
  20. homePageGameGrid.remove();
  21. }
  22. }
  23.  
  24. const allContainers = document.querySelectorAll('div.game-sort-header-container');
  25.  
  26. allContainers.forEach(container => {
  27. const headerSpan = container.querySelector('.container-header h2 span');
  28. const TheA = container.querySelector('h2').querySelector('a')
  29. console.log(TheA && TheA.textContent)
  30. if (
  31. !(TheA && (TheA.textContent == "Continue" || "Favorites"))
  32. ) {
  33. container.parentElement.remove();
  34. }
  35.  
  36. if ((headerSpan && headerSpan.textContent.trim() === "Today's Picks")) {
  37.  
  38. const parentElement = container.parentElement;
  39.  
  40. const siblingElement = parentElement.querySelector('div[data-testid="game-carousel"]');
  41. if (siblingElement) {
  42. siblingElement.remove();
  43. }
  44. container.remove();
  45. }
  46. })
  47. }
  48. window.addEventListener('load', removeRecommendedSection);
  49.  
  50. const observer = new MutationObserver((mutations) => {
  51. mutations.forEach(() => {
  52. removeRecommendedSection();
  53. });
  54. });
  55.  
  56. observer.observe(document.body, { childList: true, subtree: true });