Reddit Server Error Banner Remover

Removes the "We had a server error..." banner from Reddit.

// ==UserScript==
// @name         Reddit Server Error Banner Remover
// @namespace    https://greasyfork.org/users/1365460-kinghenry2k
// @version      1.0
// @description  Removes the "We had a server error..." banner from Reddit.
// @license      MIT
// @match        https://*.reddit.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Searches through all Shadow DOM roots for the banner
    function deepQuerySelectorAll(selector) {
        const nodes = [];
        function searchInNode(node) {
            if (node.shadowRoot) {
                const matches = node.shadowRoot.querySelectorAll(selector);
                if (matches.length > 0) {
                    nodes.push(...matches);
                }
                Array.from(node.shadowRoot.children).forEach(searchInNode);
            }
            Array.from(node.children).forEach(searchInNode);
        }
        searchInNode(document);
        return nodes;
    }

    // Removes the error banner from the DOM
    function removeErrorBanner() {
        const banners = deepQuerySelectorAll('div.banner.error');
        if (banners.length > 0) {
            banners.forEach(banner => {
                banner.remove(); // Remove the banner
            });
            console.log("Server Error Banner has been removed.");
        }
    }

    // Using MutationObserver to monitor DOM changes
    const observer = new MutationObserver(() => {
        removeErrorBanner(); // Remove banner when changes are detected
    });

    // Start observing changes in the document
    observer.observe(document, { childList: true, subtree: true });

    // Initial run to remove banner if it's already present
    removeErrorBanner();

})();