LiteTube

Hide video recommendations from listing and remove annoying auto-mix playlists to reduce lag and improve performance

Versione datata 08/11/2025. Vedi la nuova versione l'ultima versione.

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         LiteTube
// @namespace    http://tampermonkey.net/
// @version      v1.2
// @description  Hide video recommendations from listing and remove annoying auto-mix playlists to reduce lag and improve performance
// @author       Liminality Dreams
// @match        https://www.youtube.com/*
// @icon         https://img.icons8.com/?size=100&id=62852&format=png&color=228BE6
// @grant        none
// @run-at       document-start
// @license GNU 3.0
// ==/UserScript==

(function() {
    'use strict';

    let hasReloaded = false;

    function isAutoMix(listId) {
        if (!listId) return false;
        return listId.startsWith('RD') && !listId.startsWith('RDMM') && !listId.startsWith('RDAO') && !listId.startsWith('RDCLAK') && !listId.startsWith('RDTM') && !listId.startsWith('RDEM') && !listId.startsWith('RDPN');
    }

    function isWatchPage() {
        return window.location.pathname === '/watch';
    }

    function checkAndReload() {
        if (!isWatchPage() || hasReloaded) return;

        const url = new URL(window.location.href);
        const listParam = url.searchParams.get('list');

        if (listParam && isAutoMix(listParam)) {
            hasReloaded = true;
            url.searchParams.delete('list');
            url.searchParams.delete('start_radio');
            url.searchParams.delete('index');
            window.location.replace(url.toString());
        }
    }

    function removeWatchPageSidebar() {
        if (!isWatchPage()) return;
        document.querySelectorAll('#secondary').forEach(el => el.remove());
        document.querySelectorAll('ytd-watch-next-secondary-results-renderer').forEach(el => el.remove());
    }

    function removeBloat() {
        const bloatSelectors = [
            'ytd-rich-shelf-renderer[is-gaming]',
            'ytd-statement-banner-renderer',
            'ytd-banner-promo-renderer',
            'ytd-compact-promoted-video-renderer',
            'ytd-display-ad-renderer',
            'ytd-promoted-sparkles-web-renderer'
        ];
        bloatSelectors.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => el.remove());
        });
    }

    const style = document.createElement('style');
    style.textContent = `
        body[is-watch-page] #secondary,
        body[is-watch-page] ytd-watch-next-secondary-results-renderer,
        ytd-playlist-panel-renderer,
        .ytp-playlist-menu {
            display: none !important;
        }
    `;
    document.head.appendChild(style);

    checkAndReload();

    const observer = new MutationObserver(() => {
        if (isWatchPage()) {
            removeWatchPageSidebar();
        }
        removeBloat();
    });

    const startObserver = () => {
        if (document.body) {
            observer.observe(document.body, {
                subtree: true,
                childList: true
            });
        }
    };

    if (document.body) {
        startObserver();
    } else {
        document.addEventListener('DOMContentLoaded', startObserver);
    }

    window.addEventListener('yt-navigate-finish', () => {
        hasReloaded = false;
        checkAndReload();
        if (isWatchPage()) {
            setTimeout(removeWatchPageSidebar, 100);
        }
    });

})();