tubeproxy/hook.js

35 lines
888 B
JavaScript
Raw Normal View History

2021-04-05 10:04:13 +00:00
// Based on: https://github.com/metiis/invidious-redirect/blob/master/makehook.js
function checkRedirect() {
const dest = "tube.netflux.io";
let href = window.location.href;
2021-04-05 10:04:13 +00:00
// do not redirect Youtube consent page
if (href.includes("consent.youtube.com")) {
return
}
2021-04-05 10:04:13 +00:00
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;
}
2021-04-05 10:04:13 +00:00
}
checkRedirect()