Greasy Fork

Greasy Fork is available in English.

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!

当前为 2025-06-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         Roblox Home Page Cleaner
// @namespace    Roblox Recommended and Sponsored remover
// @version      6.1.5
// @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==
//Will Roblox ever STOP changing things and breaking every script?????????
(() => {
    let showTodaysPicks = false;
    let styleEl;

    const recommendedSelectors = [
        '.game-home-page-container > div:nth-of-type(1) > div:nth-of-type(3)',
        '.game-home-page-container > div:nth-of-type(1) > div:nth-of-type(5)',
        '.game-home-page-container > div:nth-of-type(1) > div:nth-of-type(6)'
    ];

    function getRecommendedCSS(hide = true) {
        return recommendedSelectors.map(sel => `${sel} { display: ${hide ? 'none !important' : ''}; }`).join('\n');
    }

    function findTodaysPicks() {
        return [...document.querySelectorAll('.game-sort-carousel-wrapper')]
            .find(wrapper => {
                const titleSpan = wrapper.querySelector('[data-testid="text-icon-row-text"]');
                return titleSpan && titleSpan.textContent.trim() === "Today's Picks";
            }) || null;
    }

    function removeFriendsTile() {
        const tile = document.querySelector('.friends-carousel-list-container > div.friends-carousel-tile:nth-of-type(1) > [href*="/users/friends"]');
        tile?.parentElement?.remove();
    }

    function injectCSS(css) {
        if (!styleEl) {
            styleEl = document.createElement('style');
            styleEl.id = 'roblox-cleaner-style';
            document.head.appendChild(styleEl);
        }
        styleEl.textContent = css;
    }

    function update() {
        const todaysPicks = findTodaysPicks();
        if (todaysPicks) todaysPicks.style.display = showTodaysPicks ? '' : 'none';
        injectCSS(getRecommendedCSS(true));
        removeFriendsTile();
    }

    function createToggleButton() {
        const nav = document.querySelector('ul.nav.rbx-navbar');
        if (!nav || document.getElementById('toggle-todays-picks-btn')) return;

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

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

        btn.onclick = e => {
            e.preventDefault();
            showTodaysPicks = !showTodaysPicks;
            update();
        };

        li.appendChild(btn);
        nav.appendChild(li);
    }

    createToggleButton();
    update();

    let timeout;
    new MutationObserver(() => {
        clearTimeout(timeout);
        timeout = setTimeout(update, 100);
    }).observe(document.body, { childList: true, subtree: true });

    setInterval(update, 3000);
})();