YouTube - Hide chats by default

Hide chats on YouTube live videos by default.

Verze ze dne 09. 09. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         YouTube - Hide chats by default
// @namespace    amekusa.yt-hide-chats
// @author       amekusa
// @version      1.0.0
// @description  Hide chats on YouTube live videos by default.
// @match        https://www.youtube.com/*
// @run-at       document-start
// @grant        none
// @license      MIT
// @homepage     https://github.com/amekusa/monkeyscripts
// ==/UserScript==

(function (doc) {
	// --- config ---
	let interval = 1000;
	let debug = true ? console.debug : (() => {});
	// --------------

	let watcher;

	let update = () => {
		let frame = doc.querySelector('iframe#chatframe');
		debug('frame:', frame);
		if (!frame) return;

		let btn = frame.contentWindow.document.querySelector('yt-live-chat-renderer #close-button button');
		debug('button:', btn);
		if (!btn) return;

		clearInterval(watcher);
		btn.dispatchEvent(new Event('click'));
		debug('done.');
	};

	doc.addEventListener('DOMContentLoaded', () => {
		update();
		watcher = setInterval(update, interval);
	});

})(document);