您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Maximizes the YouTube player to fill the entire browser viewport when in theater mode
当前为
- // ==UserScript==
- // @name YouTube Maximizer
- // @namespace http://tampermonkey.net/
- // @license MIT
- // @version 1.1
- // @description Maximizes the YouTube player to fill the entire browser viewport when in theater mode
- // @author sharlxeniy <sharlxeniy@gmail.com>
- // @match https://www.youtube.com/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // 定义样式表
- const styleSheet = `
- #masthead-container {
- transition: opacity 0.3s ease;
- opacity: 0; /* 初始隐藏顶部导航栏 */
- pointer-events: none;
- }
- #page-manager {
- margin-top: 0 !important;
- }
- #full-bleed-container {
- height: 100vh !important; /* 填满屏幕 */
- max-height: 100vh !important;
- }
- #movie_player {
- width: 100vw !important; /* 视频宽度为全屏 */
- height: 100vh !important; /* 视频高度为全屏 */
- }
- `;
- function addStyles() {
- if (!document.querySelector('#custom-youtube-style')) {
- const style = document.createElement('style');
- style.id = 'custom-youtube-style';
- style.textContent = styleSheet;
- document.head.appendChild(style);
- }
- }
- function isWatchPage() {
- return location.pathname === '/watch';
- }
- function updateStyles() {
- if (isWatchPage() && document.cookie.includes('wide=1')) {
- addStyles();
- } else {
- const style = document.querySelector('#custom-youtube-style');
- if (style) style.remove();
- }
- }
- function handleScroll() {
- const navbar = document.querySelector('#masthead-container');
- if (!navbar) return;
- if (window.scrollY > 0) {
- navbar.style.opacity = '1';
- navbar.style.pointerEvents = 'auto';
- } else {
- navbar.style.opacity = '0';
- navbar.style.pointerEvents = 'none';
- }
- }
- const observer = new MutationObserver(updateStyles);
- observer.observe(document.body, { childList: true, subtree: true });
- window.addEventListener('scroll', handleScroll);
- updateStyles();
- })();