mirror of
https://github.com/TeamPiped/Piped-Redirects.git
synced 2024-08-14 23:57:14 +00:00
parent
0002eb04d7
commit
6af1f49429
2 changed files with 12 additions and 2 deletions
|
@ -1,12 +1,22 @@
|
|||
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(
|
||||
(details) => {
|
||||
const url = new URL(details.url);
|
||||
if (url.hostname.endsWith("youtu.be") && url.pathname.length > 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";
|
||||
return { redirectUrl: url.href };
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Piped Redirects",
|
||||
"version": "1.1",
|
||||
"version": "1.2",
|
||||
"description": "Redirects YouTube links to Piped",
|
||||
"permissions": [
|
||||
"webRequest",
|
||||
|
|
Loading…
Reference in a new issue