Redirect YT video to embedded video

Redirects any opened YT video to the YT embedded video to make the video take the whole screen.

Install this script?
Author's suggested script

You may also like Auto Set Youtube Volume.

Install this script
// ==UserScript==
// @name         Redirect YT video to embedded video
// @namespace    YTRedir
// @version      14
// @description  Redirects any opened YT video to the YT embedded video to make the video take the whole screen.
// @author       hacker09
// @include      https://m.youtube.com/*
// @include      https://www.youtube.com/*
// @icon         https://www.youtube.com/s/desktop/03f86491/img/favicon.ico
// @run-at       document-start
// @grant        none
// @noframes
// ==/UserScript==

(function() {
  'use strict';

  function Run() { //Creates a new function
    if ((location.pathname !== '/') && (location.href.match('/watch') !== null) && (location.href.match(/&list=|&t=1s|embed/) === null)) //As long as it's not the YT index page, the URL is a video, it's not a playlist/embedded video, and doesn't have '&t=1s' in the end of the URL
    { //Starts the if condition
      const YTID = location.href.split(/(vi\/|v%3D|v=|\/v\/|youtu\.be\/|\/embed\/)/)[2].split(/[^0-9a-z_\-]/i)[0]; //Store the YT video ID
      location = 'https://www.youtube.com/embed/' + YTID + '?autoplay=1&mute=1'; //Redirect to the embedded YT URL
    } //Finishes the if condition
  } //Finishes the Run function

  Run(); //Calls the Run function

  window.ontransitionrun = function() { //When the video is changed
    Run(); //Calls the Run function
  }; //Finishes the transitionend event listener

  window.onload = function() { //When the page loads
    if (location.href.match('embed') !== null) //As long as the URL is an embedded video
    { //Starts the if condition
      document.querySelector("a.ytp-title-link").outerHTML = document.querySelector("a.ytp-title-link").outerHTML; //Remove the event listeners of the element
      document.querySelector("a.ytp-title-link").href += '&t=1s'; //Add url parameter to start video on the first second of the video, so that the script won't redirect the URL
      document.querySelector("a.ytp-title-link").target = '_self'; //Open the video in the same tab
      document.querySelector(".ytp-button.yt-uix-sessionlink").outerHTML = document.querySelector(".ytp-button.yt-uix-sessionlink").outerHTML; //Remove the event listeners of the element
      document.querySelector(".ytp-button.yt-uix-sessionlink").href += '&t=1s'; //Add url parameter to start video on the first second of the video, so that the script won't redirect the URL
      document.querySelector(".ytp-button.yt-uix-sessionlink").target = '_self'; //Open the video in the same tab
      if (navigator.userAgent.match('Mobile') !== null) //If the embedded video is being played on a mobile device
      { //Starts the if condition
        document.querySelector('#movie_player').playVideo(); //Play the video
      } //Finishes the if condition
    } //Finishes the if condition
  }; //Finishes the onload event listener
})();