jaidedctrl / Invidious Redirect

// ==UserScript==
// @name         Invidious Redirect
// @description  Redirect YouTube to Invidious.
// @author       jaidedctrl
// @license      GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @match        *://*youtube.com/*
// @run-at       document-start
// ==/UserScript==
 
var invInstance = "https://invidious.snopyta.org";
 
var url = window.location.href;
if ( url.match("youtube.com") != null ) {
        url = url.replace( /.*youtube.com/, invInstance );
    	window.location.replace( url );
}