YouTube Embed Player on Watch Page

Replace YouTube watch page player with the embed player for distraction-free viewing

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         YouTube Embed Player on Watch Page
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Replace YouTube watch page player with the embed player for distraction-free viewing
// @author       GPT
// @match        https://www.youtube.com/watch*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Get video ID from URL
    const urlParams = new URLSearchParams(window.location.search);
    const videoId = urlParams.get("v");

    if (videoId) {
        // Replace the entire body with an embedded player iframe
        document.body.innerHTML = `
            <div style="display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #000;">
                <iframe width="100%" height="100%" style="border: none;" src="https://www.youtube.com/embed/${videoId}?autoplay=1" allowfullscreen></iframe>
            </div>
        `;
    }
})();