YouTube To Invidious Button

Adds a button to redirect from YouTube to an Invidious instance

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 or Violentmonkey 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 To Invidious Button
// @version      1.0
// @description  Adds a button to redirect from YouTube to an Invidious instance
// @author       Rust1667
// @match        *://www.youtube.com/*
// @namespace https://greasyfork.org/users/980489
// ==/UserScript==

(function() {
    'use strict';

    const invInstances = [
          'redirect.invidious.io',
          'inv.nadeko.net',
          'invidious.nerdvpn.de',
          'invidious.privacyredirect.com',
          'invidious.jing.rocks',
        ];
    const invInstance = invInstances[Math.floor(Math.random() * invInstances.length)];

    var button = document.createElement('button');
    button.innerHTML = 'Redirect to Invidious';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.right = '300px';
    button.style.zIndex = '10000';
    button.style.padding = '10px';
    button.style.backgroundColor = '#ff0000';
    button.style.color = '#ffffff';
    button.style.border = 'none';
    button.style.borderRadius = '5px';
    button.style.cursor = 'pointer';
    document.body.appendChild(button);

    button.onclick = function () {
        window.location.assign(window.location.toString().replace('www.youtube.com', invInstance));
    };

})();