Remove youtube topbar on theater mode

Removes the youtube topbar when theater mode is on

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Remove youtube topbar on theater mode
// @description Removes the youtube topbar when theater mode is on
// @namespace   nah
// @include     https://www.youtube.com/watch?*
// @version     1
// @grant       none
// @run-at      document-end
// ==/UserScript==

var mainPage = document.getElementById("page");
var stageModeButton = document.getElementsByClassName("ytp-size-button ytp-button")[0];
var topBar = document.getElementById("masthead-positioner");
var topBarHeightOffest = document.getElementById("masthead-positioner-height-offset");

function isStageMode() {
  return mainPage.classList.contains("watch-stage-mode");
}
function toggleMe(element, show){
  if(element){
    if(show)
      element.style.visibility = "visible";
    else
      element.style.visibility = "collapse";
  }
}
function refreshTopBar(show){
  toggleMe(topBar, show);
  toggleMe(topBarHeightOffest, show);
  if(show)
    topBarHeightOffest.style.height = "50px";
  else
    topBarHeightOffest.style.height = "0px";
}

document.getElementsByClassName("ytp-size-button ytp-button")[0].onclick = function(){
  refreshTopBar(isStageMode());
}
refreshTopBar(!isStageMode());