YouTube To Invidious Button

Adds a button to redirect from YouTube to an Invidious instance

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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));
    };

})();