Reddit Cleanup

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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);
    }

})();