Greasy Fork

Greasy Fork is available in English.

Invidious Redirect

Redirect YouTube video link to Invidious instances

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Invidious Redirect
// @description Redirect YouTube video link to Invidious instances
// @namespace   io.github.zeinok.invidiousRedirect
// @match       *://youtube.com/watch
// @match       *://*.youtube.com/watch
// @match       *://youtu.be/
// @run-at      document-start
// @grant       none
// @version     1.01
// @author      Zeinok
// ==/UserScript==

/* CONFIG */
// List of invidious instances, will be randomly chosen upon redirection.
// URI schema (https://) is required.
// View list of instances here: https://instances.invidio.us
const instances = ["https://invidious.snopyta.org", "https://yewtu.be", "https://invidious.xyz", "https://yewtu.be/"];

/* SCRIPT START */
let url = new URL(window.location);
let redirectURL = new URL(instances[Math.floor(Math.random()*instances.length)])
let pathname = url.pathname.substring(1);
let videoID = url.searchParams.get("v");
let time = url.searchParams.get("t");

redirectURL.pathname = "/watch";
if(!videoID)
  videoID = pathname;
redirectURL.searchParams.set("v", videoID);
if(time)
  redirectURL.searchParams.set("t", time);

window.location = redirectURL.toString();