Greasy Fork

Greasy Fork is available in English.

Roblox Home Cleaner

Roblox Home Page Cleaner with the option to toggle on or off "Today's Picks", previously known as Roblox Recommended, Sponsored and Events remover

// ==UserScript==
// @name         Roblox Home Cleaner
// @namespace    Roblox Recommended and Sponsored remover
// @version      6.1.1
// @description  Roblox Home Page Cleaner with the option to toggle on or off "Today's Picks", previously known as Roblox Recommended, Sponsored and Events remover
// @author       Vexdll
// @match        https://*.roblox.com/home
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

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

    function addNavBarButton() {
        const navBar = document.querySelector('.navbar, .rbx-navbar');
        if (!navBar) return;

        const navBarItems = navBar.querySelector('.navbar-right') || navBar;
        const toggleButton = document.createElement('a');

        toggleButton.textContent = 'Toggle Today\'s Picks';
        Object.assign(toggleButton.style, {
            userSelect: 'none',
            padding: '6px 9px',
            display: 'inline-block',
            color: '#fff',
            fontSize: '14px',
            textDecoration: 'none',
            cursor: 'pointer',
            textAlign: 'center',
            position: 'relative',
        });

        GM_addStyle(`
            a::after {
                content: '';
                position: absolute;
                bottom: 0;
                left: 50%;
                right: 50%;
                height: 2px;
                background-color: transparent;
                transition: all 0.3s ease;
            }
            a:hover::after {
                left: 0;
                right: 0;
                background-color: #fff;
            }
        `);

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

        navBarItems.appendChild(toggleButton);
    }

    function cleanHomePage() {
        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 });

    addNavBarButton();
    cleanHomePage();
})();