Youtube Full Theater

Makes YouTube's theater mode fill the screen

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 Full Theater
// @name:fr			Youtube Full Theater
// @description		Makes YouTube's theater mode fill the screen
// @description:fr	Fait que le mode cinéma de YouTube remplisse la fenêtre
// @author			PsychoPatate
// @license			GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @namespace		https://github.com/PsychoPatate
// @version			1.1
// @source			https://github.com/PsychoPatate/Youtube-Full-Theater
// @iconURL			https://raw.githubusercontent.com/PsychoPatate/Youtube-Full-Theater/main/icon128.png
// @icon64URL		https://raw.githubusercontent.com/PsychoPatate/Youtube-Full-Theater/main/icon64.png
// @supportURL		https://github.com/PsychoPatate/Youtube-Full-Theater/issues
// @require			https://code.jquery.com/jquery-3.5.1.min.js
// @run-at 			document-end
// @noframes
// @match			https://www.youtube.com/watch*
// ==/UserScript==


(function() {
	'use strict';

	var fsMode = 0;

	// Resize theatre player as soon as it exists
	var tries = 0;
	var checkExist = setInterval(function() {
		if (tries++ > 3)
			clearInterval(checkExist);
		if ($('#player-theater-container').length) {
			$('#player-theater-container').css("max-height", "calc(100vh - 56px)");
			clearInterval(checkExist);
		}
	}, 500);

	// Restore height when clicking fullscreen button
	$('.ytp-fullscreen-button').click(function() {
		if (fsMode == 0) {
			$('#player-theater-container').css("max-height", "");
			fsMode = 1;
		}
		else if (fsMode == 1) {
			$('#player-theater-container').css("max-height", "calc(100vh - 56px)");
			fsMode = 0;
		}
	});

	// Restore height when double clicking video
	$('#player-theater-container').dblclick(function() {
		if (fsMode == 0) {
			$('#player-theater-container').css("max-height", "");
			fsMode = 1;
		}
		else if (fsMode == 1) {
			$('#player-theater-container').css("max-height", "calc(100vh - 56px)");
			fsMode = 0;
		}
	});

	// Restore height when pressing fullscreen key
	document.addEventListener("keyup",function(event){
		if(event.keyCode === 70) {
			if (fsMode == 0) {
				$('#player-theater-container').css("max-height", "");
				fsMode = 1;
			}
			else if (fsMode == 1) {
				$('#player-theater-container').css("max-height", "calc(100vh - 56px)");
				fsMode = 0;
			}
		}
	});
})();