tubeproxy/hook.js

35 lines
888 B
JavaScript

// Based on: https://github.com/metiis/invidious-redirect/blob/master/makehook.js
function checkRedirect() {
const dest = "tube.netflux.io";
let href = window.location.href;
// do not redirect Youtube consent page
if (href.includes("consent.youtube.com")) {
return
}
if (href.includes("m.youtube.com")) {
href = href.replace("m.youtube.com", dest);
} else if (href.includes("www.youtube.com")) {
href = href.replace("www.youtube.com", dest);
} else if (href.includes("youtu.be")) {
href = href.replace("youtu.be/", dest + "/watch?v=");
}
if (href.includes("/results?q")) {
href = href.replace("/results?q", "/search?q");
}
if (href.includes("/results?search_query")) {
href = href.replace("/results?search_query", "/search?q");
}
if(confirm("Redirect to " + href + "?")) {
window.location.href = href;
}
}
checkRedirect()