YouTube To Invidious Button

Adds a button to redirect from YouTube to an Invidious instance

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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

})();