Reddit Cleanup

Hide Reddit elements to hide/clear (Check code to configure what to hide).

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

You will need to install an extension such as Tampermonkey to install this script.

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Reddit Cleanup
// @description  Hide Reddit elements to hide/clear (Check code to configure what to hide).
// @author       senji
// @version      1.0
// @license      GNU GPLv3
// @namespace    http://tampermonkey.net/
// @match        *://*.reddit.com/*
// @grant        none
// @run-at       document-start
// @icon         https://files.catbox.moe/7ovpr1.png
// ==/UserScript==

(function () {
    'use strict';

    // replace values with 'true' or 'false' depending on what you want to hide //
    const clearRecentSearches = true;
    const hideRecentPosts = true;

    // sidebar
    const hideEntireSidebar = false;
    const hideStartCommunity = true;
    const hideGamesOnReddit = true;
    const hideCustomFeeds = true;
    const hideRecentSubs = true;
    const hideCommunities = true;
    const hideRedditResources = true;

    if (!window.location.hostname.endsWith('reddit.com')) return;

    // clears your recent searches from the search bar
    if (clearRecentSearches) {
        localStorage.removeItem('recent-searches-store');
    }

    let css = '';

    // hides entire sidebar (overrides other sidebar options)
    if (hideEntireSidebar) {

        css += `
            #flex-left-nav-container {
                display: none !important;
            }
        `;

    } else {

        // hides Explore button in sidebar
        if (hideStartCommunity) {
            css += `
                li[slot="sr-creation-entrypoint-experiment"] {
                    display: none !important;
                }
            `;
        }

        // hides the Reddit Games tab on the sidebar
        if (hideGamesOnReddit) {
            css += `
                faceplate-tracker[noun="games_drawer"],
                faceplate-tracker[noun="games_drawer"] + hr {
                    display: none !important;
                }
            `;
        }

        if (hideCustomFeeds) {
            css += `
                faceplate-expandable-section-helper:has(> details > summary[aria-controls="multireddits_section"]),
                faceplate-expandable-section-helper:has(> details > summary[aria-controls="multireddits_section"]) + hr {
                    display: none !important;
                }
            `;
        }

        // hides your recently visited subreddits on the sidebar
        if (hideRecentSubs) {
            css += `
                #recent-communities-section {
                    display: none !important;
                }
            `;
        }

        // hides your communities (the subs you're in) subreddits on the sidebar
        if (hideCommunities) {
            css += `
                details:has(> summary[aria-controls="communities_section"]),
                faceplate-loader[name^="CommunityCreationFlow"],
                faceplate-partial[name^="CommunityCreationFlow"],
                faceplate-partial[name^="CommunityCreationFlow"] + hr {
                    display: none !important;
                }
            `;
        }

        // hides the Reddit resources section on the sidebar
        if (hideRedditResources) {
            css += `
                nav[aria-label="Reddit resources"] {
                    display: none !important;
                }
            `;
        }

    }

    // hides your recently visited posts on reddit homepage
    if (hideRecentPosts) {
        css += `
            recent-posts,
            [recent-post-ids] {
                display: none !important;
            }
        `;
    }

    // other stuff to hide
    css += `
        a[href="https://redditinc.com"] {
            display: none !important;
        }

        .legal-links {
            display: none !important;
        }

        [data-part="advertise"] {
            display: none !important;
        }
    `;


    if (css.trim()) {
        const style = document.createElement('style');
        style.textContent = css;
        document.documentElement.appendChild(style);
    }

})();