Redirect YT video to embedded video

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

As of 20. 11. 2021. See the latest version.

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

(function() {
  'use strict';

  function Run() { //Creates a new function
    if (location.href.match('&list=') === null) //As long as it's not a playlist
    { //Starts the if condition
      const NoFeature = location.href.replace('&feature=emb_title', ''); //Remove the feature URL parameters
      const YTID = 'https://www.youtube.com/embed/' + location.search.replace('?v=', '') + '?autoplay=1'; //Store embedded URL
      location = NoFeature.replace(location.href, YTID); //Redirect the YT Link
    } //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
})();