YouTube chat minimized

Hide live chat on live streams

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           YouTube chat minimized
// @name:es        YouTube chat minimizado
// @description    Hide live chat on live streams
// @description:es Esconde el chat de las transmisiones en vivo
// @version        0.5
// @author         IgnaV
// @match          https://www.youtube.com/*
// @icon           http://youtube.com/favicon.ico
// @namespace      http://tampermonkey.net/
// @license        MIT
// @grant          none
// ==/UserScript==

(function() {
    'use strict';

    const hideChat = () => {
        let attemptsToHide = 0;
        const intervalId = setInterval(() => {
            const chat = document.querySelector('#show-hide-button > ytd-toggle-button-renderer');

            if (chat) {
                chat.click();
                console.log('Chat hidden!');
                clearInterval(intervalId);
                return;
            } else if (attemptsToHide < 20) {
                attemptsToHide++;
                console.log(`Attempts to hide the chat ${attemptsToHide}`);
            } else {
                clearInterval(intervalId);
            }
        }, 1000);
    }
    window.addEventListener('urlchange', hideChat);
    hideChat();
})();