YouTube Watch Page Chat-Replay CSS

Customize video and chat layout on YouTube watch page

目前為 2025-05-15 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Watch Page Chat-Replay CSS
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Customize video and chat layout on YouTube watch page
// @match        https://www.youtube.com/watch?v=*
// @grant        none
// @license      CC0
// ==/UserScript==


(function () {
    'use strict';
		
  	let styleElement = null;
  	const css = `/* video */
#player, .html5-main-video, #movie_player {
    position: absolute !important;
    top: 0px !important;
    left: 0px !important;
    width: calc(100vw - 420px) !important;
    height: calc(105vh - 58px) !important;
    object-fit: contain !important;
    border: 1px solid #000 !important;
}
.ytp-chrome-bottom {
    width: 100vw !important;
}

/* chat */
#chat {
    position: absolute !important;
    top: -56px !important;
    left: 4px !important;
    
    width: 420px !important;
    height: 100vh !important;
    overflow-y: auto !important;
    border-radius: 0px !important;
    border: 1px solid #333 !important;
}

/* hide everything else */
#above-the-fold, .ytd-watch-metadata, #comments, #chips, .ytd-watch-next-secondary-results-renderer, .ytd-masthead, #end {
    display: none !important;
}

`
  	
    document.addEventListener('keydown', function (e) {
        // Use F2 as toggle key
        if (e.key === 'F2') {
            if (styleElement) {
                styleElement.remove();
                styleElement = null;
            
            } else {
                styleElement = document.createElement('style');
                styleElement.textContent = css;
                document.head.appendChild(styleElement);
            }
        }
    });
})();