Invidious Redirect

Redirect YouTube video link to Invidious instances

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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