Roblox Home Page Cleaner

Roblox Home Page Cleaner lets you toggle Today's Picks on or off. It also gets rid of the Add Friends button and any other random trash Roblox throws on the homepage!

// ==UserScript==
// @name         Roblox Home Page Cleaner
// @namespace    Roblox Recommended and Sponsored remover
// @version      6.1.4
// @description  Roblox Home Page Cleaner lets you toggle Today's Picks on or off. It also gets rid of the Add Friends button and any other random trash Roblox throws on the homepage!
// @author       Krex
// @match        https://*.roblox.com/home
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

    const ALLOWED_SECTIONS = ["Continue", "Favorites"];
    let showTodaysPicks = false;

function ToggletodaysPicksButton() {
    const navList = document.querySelector('ul.nav.rbx-navbar');
    if (!navList) return;

    const listItem = document.createElement('li');
    listItem.className = 'cursor-pointer';

    const toggleButton = document.createElement('a');
    toggleButton.textContent = "Toggle Today's Picks";
    toggleButton.href = "#";
    toggleButton.className = 'font-header-2 nav-menu-title text-header';
    toggleButton.style.userSelect = 'none';

    toggleButton.addEventListener('click', (e) => {
        e.preventDefault();
        showTodaysPicks = !showTodaysPicks;
        cleanHomePage();
    });

    listItem.appendChild(toggleButton);
    navList.appendChild(listItem);
}

    function cleanHomePage() {

const friendsTile = document.querySelector('.friends-carousel-list-container > div.friends-carousel-tile:nth-of-type(1) > [href*="/users/friends"]');
if (friendsTile && friendsTile.parentElement) {
    friendsTile.parentElement.remove();
} //will this work????? hmmmmmmmmmm
        document.querySelectorAll('h2, h3').forEach(heading => {
            const sectionTitle = heading.textContent.trim();
            const container = heading.closest(
                'div[class*="game-sort-carousel-wrapper"], div[data-testid="home-page-game-grid"]'
            );

            if (container) {
                container.style.display = 
                    ALLOWED_SECTIONS.includes(sectionTitle) || 
                    (showTodaysPicks && sectionTitle.startsWith("Today's Picks"))
                        ? ''
                        : 'none';
            }
        });
    }

    const observer = new MutationObserver(cleanHomePage);
    observer.observe(document.body, { childList: true, subtree: true });

    ToggletodaysPicksButton();
    cleanHomePage();
})();