No Relevant Subscriptions Tab

Hides and removes the Most relevant shelf from YouTube subscriptions feed.

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         No Relevant Subscriptions Tab
// @license      MIT
// @namespace    https://youtube.com/
// @version      1.0
// @description  Hides and removes the Most relevant shelf from YouTube subscriptions feed.
// @author       BergNetworks
// @match        https://www.youtube.com/feed/subscriptions
// @match        https://youtube.com/feed/subscriptions
// @run-at       document-start
// @grant        none
// @icon         data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIiB2aWV3Qm94PSIwIDAgMTAyNCA3NjgiIGZpbGw9IiMwMDAwMDAiPjxwYXRoIGZpbGw9IiMwMDAwMDAiIGQ9Ik05MjggNzM2cS0yMjIgMzItNDE2IDMycS04NiAwLTE5MC04dC0xNjUtMTZsLTYxLThxLTI3LTUtNDcuNS0zNy41dC0zMC03OC41dC0xNC04NlQwIDQ2MVYzMDdRMCA1MiA5NiAzMlEzMTggMCA1MTIgMHE4NiAwIDE5MCA4dDE2NSAxNmw2MSA4cTI5IDQgNDkuNSAzNi41VDEwMDcgMTQ4dDEzIDg2dDQgNzN2MTU0cTAgMzYtMyA3M3QtMTIgODV0LTMwIDgwdC01MSAzN3pNNjkzIDM1OUw0MzEgMTk5cS0xMS0xMC0yOS01LjVUMzg0IDIwOHYzNTJxMCAxMSAxOCAxNXQyOS02bDI2Mi0xNjBxMTEtMTAgMTEtMjV0LTExLTI1eiIvPjwvc3ZnPg==
// ==/UserScript==

(function () {
    'use strict';

    function isSubscriptionsPage() {
        return location.hostname.endsWith('youtube.com') &&
               location.pathname === '/feed/subscriptions';
    }

    function injectCss() {
        const style = document.createElement('style');
        style.textContent = `
            ytd-rich-section-renderer:has(ytd-rich-shelf-renderer #title)
            {
            }

            ytd-rich-section-renderer:has(ytd-rich-shelf-renderer #title),
            ytd-rich-section-renderer:has(span#title)
            {
            }
        `;
        document.documentElement.appendChild(style);
    }

    function removeMostRelevantShelves() {
        if (!isSubscriptionsPage()) return;

        const sections = document.querySelectorAll('ytd-rich-section-renderer');

        for (const section of sections) {
            const title = section.querySelector('#title');
            if (!title) continue;

            const text = (title.textContent || '').trim();
            if (text === 'Most relevant') {
                section.remove();
            }
        }
    }

    function startObserver() {
        const observer = new MutationObserver(() => {
            removeMostRelevantShelves();
        });

        observer.observe(document.documentElement, {
            childList: true,
            subtree: true
        });

        removeMostRelevantShelves();
    }

    function init() {
        if (!isSubscriptionsPage()) return;
        injectCss();
        removeMostRelevantShelves();
        startObserver();
    }

    window.addEventListener('yt-navigate-finish', init);
    window.addEventListener('load', init);
    init();
})();