Reddit Cleanup

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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

})();