Reddit Cleanup

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

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

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

})();