mirror of
https://github.com/TeamPiped/Piped-Redirects.git
synced 2024-08-14 23:57:14 +00:00
Initial commit
This commit is contained in:
commit
cdeb18a1c0
8 changed files with 719 additions and 0 deletions
18
js/background.js
Normal file
18
js/background.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
|
||||
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")) {
|
||||
url.hostname = "piped.kavin.rocks";
|
||||
return { redirectUrl: url.href };
|
||||
}
|
||||
},
|
||||
{
|
||||
urls: ["<all_urls>"],
|
||||
},
|
||||
["blocking"],
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue