parent
0002eb04d7
commit
6af1f49429
|
@ -1,12 +1,22 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome;
|
||||||
|
|
||||||
|
const INVIDIOUS_INSTANCES = [];
|
||||||
|
|
||||||
|
fetch("https://api.invidious.io/instances.json")
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((array) => array.forEach((json) => INVIDIOUS_INSTANCES.push(json[0])));
|
||||||
|
|
||||||
browser.webRequest.onBeforeRequest.addListener(
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
(details) => {
|
(details) => {
|
||||||
const url = new URL(details.url);
|
const url = new URL(details.url);
|
||||||
if (url.hostname.endsWith("youtu.be") && url.pathname.length > 1) {
|
if (url.hostname.endsWith("youtu.be") && url.pathname.length > 1) {
|
||||||
return { redirectUrl: "https://piped.kavin.rocks/watch?v=" + url.pathname.substr(1) };
|
return { redirectUrl: "https://piped.kavin.rocks/watch?v=" + url.pathname.substr(1) };
|
||||||
}
|
}
|
||||||
if (url.hostname.endsWith("youtube.com") || url.hostname.endsWith("youtube-nocookie.com")) {
|
if (
|
||||||
|
url.hostname.endsWith("youtube.com") ||
|
||||||
|
url.hostname.endsWith("youtube-nocookie.com") ||
|
||||||
|
INVIDIOUS_INSTANCES.includes(url.hostname)
|
||||||
|
) {
|
||||||
url.hostname = "piped.kavin.rocks";
|
url.hostname = "piped.kavin.rocks";
|
||||||
return { redirectUrl: url.href };
|
return { redirectUrl: url.href };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Piped Redirects",
|
"name": "Piped Redirects",
|
||||||
"version": "1.1",
|
"version": "1.2",
|
||||||
"description": "Redirects YouTube links to Piped",
|
"description": "Redirects YouTube links to Piped",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"webRequest",
|
"webRequest",
|
||||||
|
|
Loading…
Reference in New Issue