YouTube Embed Player on Watch Page

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

// ==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>
        `;
    }
})();