YouTube Clean & Fast (Hide UI/Spinner)

Hide all YouTube player UI (buttons, spinner, shadows, ads, branding, related videos suggestions when the video ends) immediately and show them only on mouse hover.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         YouTube Clean & Fast (Hide UI/Spinner)
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      3
// @description  Hide all YouTube player UI (buttons, spinner, shadows, ads, branding, related videos suggestions when the video ends) immediately and show them only on mouse hover.
// @author       hacker09
// @match        *://www.youtube.com/embed/*
// @match        *://www.youtube.com/watch*
// @icon         https://www.youtube.com/s/desktop/03f86491/img/favicon.ico
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  const css = `
        /* === MAIN UI HIDING (Opacity 0 when mouse is not moving) === */

        /* 1. Top Controls (Title, Share, Favicon) */
        body.tm-clean-ui .ytp-chrome-top,

        /* 2. Bottom Controls (Time, Bar, Buttons, Fullscreen) */
        body.tm-clean-ui .ytp-chrome-bottom,

        /* 3. Shadows (Gradients at top/bottom) */
        body.tm-clean-ui .ytp-gradient-top,
        body.tm-clean-ui .ytp-gradient-bottom,

        /* 4. Center Play Button */
        body.tm-clean-ui .ytp-large-play-button,

        /* 5. THE SPINNER (Buffering/Loading circle) */
        body.tm-clean-ui .ytp-spinner,

        /* 6. Bezel (Play/Pause animation icon in the middle) */
        body.tm-clean-ui .ytp-bezel-text-wrapper,
        body.tm-clean-ui .ytp-bezel,

        /* 7. Branding & Popups */
        body.tm-clean-ui .ytp-watermark,
        body.tm-clean-ui .ytp-upnext,
        body.tm-clean-ui .ytp-pause-overlay-container,
        body.tm-clean-ui .ytp-share-panel,
        body.tm-clean-ui .ytp-storyboard-framepreview,
        body.tm-clean-ui .ytp-cued-thumbnail-overlay,

        /* 8. Top Alerts (Exclude actual bottom subtitles) */
        body.tm-clean-ui .ytp-caption-window-top,

        /* 9. Suggested Ads & Products (Merch, "View Products" overlay) */
        body.tm-clean-ui .ytp-suggested-action,
        body.tm-clean-ui .ytp-featured-product,

        /* 10. Channel Branding & Quick Actions */
        body.tm-clean-ui .iv-branding,
        body.tm-clean-ui .ytp-fullscreen-quick-actions
        {
            opacity: 0 !important;
            visibility: hidden !important;
            display: none !important;
            transition: opacity 0.1s ease-out !important;
        }

        /* === EXCEPTIONS (Always Visible) === */

        /* Ensure Subtitles are visible */
        body.tm-clean-ui .ytp-caption-window-bottom {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }

        /* Ensure Video is visible */
        body.tm-clean-ui .html5-main-video {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }

        /* === END SCREEN SUGGESTIONS (Fully Hidden by default) === */
        /* Keep them at 0 opacity so they don't block the video ending view at all.
           Only show fully when the mouse is directly over the specific element area.
           We must keep visibility:visible so the hover event can still trigger. */
        .ytp-ce-element {
            opacity: 0 !important;
            transition: opacity 0.2s ease-in-out !important;
        }
        .ytp-ce-element:hover {
            opacity: 1 !important;
        }

        /* === RESTORE MAIN UI ON HOVER (General Area) === */
        .ytp-chrome-top,
        .ytp-chrome-bottom,
        .ytp-caption-window-top {
            transition: opacity 0.1s ease-in !important;
        }
    `;

  // Inject CSS immediately
  const styleNode = document.createElement('style');
  styleNode.type = 'text/css';
  styleNode.appendChild(document.createTextNode(css));
  (document.head || document.documentElement).appendChild(styleNode);

  // Logic to toggle the class
  function initLogic() {
    const targetBody = document.body;
    targetBody.classList.add('tm-clean-ui');

    const hideUI = () => targetBody.classList.add('tm-clean-ui');
    const showUI = () => targetBody.classList.remove('tm-clean-ui');

    // Show on mouse enter/move within the player body area
    targetBody.addEventListener('mouseenter', showUI, false);
    targetBody.addEventListener('mousemove', showUI, false);

    // Hide on mouse leave the player body area
    targetBody.addEventListener('mouseleave', hideUI, false);
  }

  // Initialize
  if (document.body) {
    initLogic();
  } else {
    document.addEventListener('DOMContentLoaded', initLogic);
  }
})();