41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
// ==UserScript==
|
|
// @name Youtube to Invidious redirector
|
|
// @namespace youtube_to_invidious_redirector
|
|
// @description Redirect Youtube links to Invidious
|
|
// @include https://www.youtube.com/
|
|
// @include https://www.google.com/sorry/index*
|
|
// @include https://invidious.13ad.de/channel/*
|
|
// @version 1.0
|
|
// @grant none
|
|
// ==/UserScript==
|
|
|
|
// Redirect from google error page
|
|
if (window.location.host === "www.google.com") {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
let cont = urlParams.get('continue');
|
|
|
|
cont = decodeURI(cont);
|
|
cont = cont.replace( "www.youtube.com", getInstance() );
|
|
|
|
window.location = cont;
|
|
|
|
// Redirect youtube
|
|
} else if (window.location.host === "www.youtube.com") {
|
|
// window.location = window.location.href.replace( "www.youtube.com", getInstance() );
|
|
|
|
// Fix instance issues
|
|
} else {
|
|
window.location = window.location.href.replace( "invidious.13ad.de/channel", "invidious.snopyta.org/channel" );
|
|
}
|
|
|
|
|
|
function getInstance() {
|
|
const instances = [
|
|
"invidious.snopyta.org",
|
|
"yewtu.be",
|
|
"invidious.13ad.de"
|
|
];
|
|
// return instances[0];
|
|
return instances[Math.floor(Math.random() * instances.length)]
|
|
}
|