Youtube Max Video Height

A simplified userscript to maximize height of youtube media player with no interaction

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Youtube Max Video Height
// @namespace   Youtube Max Video Height
// @match       https://*.youtube.com/*
// @grant       GM_addStyle
// @version     1.0.0
// @author      popiazaza (original), dpi0 (modified)
// @description A simplified userscript to maximize height of youtube media player with no interaction
// @license     MIT
// @homepageURL https://github.com/dpi0/scripts/blob/main/greasyfork/youtube-max-video-height.js
// @originalhomepageURL https://github.com/popiazaza/Youtube-Max-Video-Height
// @supportURL  https://github.com/dpi0/scripts/issues
// ==/UserScript==

GM_addStyle(`
ytd-watch-flexy[theater] #player-wide-container.ytd-watch-flexy, 
ytd-watch-flexy[fullscreen] #player-wide-container.ytd-watch-flexy, 
ytd-watch-flexy[full-bleed-player] #full-bleed-container.ytd-watch-flexy, 
ytd-watch-flexy[full-bleed-player] #full-bleed-container.ytd-watch-flexy {
  max-height: calc(100vh);
}
#masthead-container.ytd-app {
  opacity: 0;
  pointer-events: none;
}
#page-manager.ytd-app {
  margin-top: 0;
}
`);

(function() {
  // Set different styles for non-watch pages
  const observer = new MutationObserver(() => {
    const masthead = document.getElementById("masthead-container");
    if (!masthead) return;
    
    if (window.location.pathname.startsWith("/watch")) {
      // On watch pages, hide header and disable interactions
      masthead.style.opacity = "0";
      masthead.style.pointerEvents = "none";
      document.getElementById("page-manager").style.marginTop = "0";
    } else {
      // On non-watch pages, show header and enable interactions
      masthead.style.opacity = "1";
      masthead.style.pointerEvents = "auto";
      document.getElementById("page-manager").style.marginTop = 
        "var(--ytd-masthead-height,var(--ytd-toolbar-height))";
    }
  });
  
  // Run initially and observe for changes
  observer.observe(document, { subtree: true, childList: true });
  
  // Initial setup
  if (document.getElementById("masthead-container")) {
    if (window.location.pathname.startsWith("/watch")) {
      document.getElementById("masthead-container").style.opacity = "0";
      document.getElementById("masthead-container").style.pointerEvents = "none";
      document.getElementById("page-manager").style.marginTop = "0";
    } else {
      document.getElementById("masthead-container").style.opacity = "1";
      document.getElementById("masthead-container").style.pointerEvents = "auto";
      document.getElementById("page-manager").style.marginTop = 
        "var(--ytd-masthead-height,var(--ytd-toolbar-height))";
    }
  }
})();