Remove Reddit Recent Posts Sidebar

Remove the "Recent Posts" sidebar on Reddit.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Remove Reddit Recent Posts Sidebar
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Remove the "Recent Posts" sidebar on Reddit.
// @author       Rayman30
// @match        https://www.reddit.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove the Recent Posts sidebar
    function removeRecentPosts() {
        // Select the <recent-posts> element
        const recentPosts = document.querySelector('recent-posts');

        if (recentPosts) {
            recentPosts.remove(); // Remove the entire element
            console.log('Recent Posts removed.');
        } else {
            console.log('Recent Posts not found.');
        }
    }

    // Run the function on initial page load
    document.addEventListener('DOMContentLoaded', removeRecentPosts);

    // Observe dynamically loaded content
    const observer = new MutationObserver(() => {
        removeRecentPosts();
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();