feat: take care of github
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
browser.webRequest.onBeforeRequest.addListener(
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
function(details) {
|
function(details) {
|
||||||
|
//console.log(details);
|
||||||
const url = new URL(details.url);
|
const url = new URL(details.url);
|
||||||
if (url.hostname === "www.youtube.com" || url.hostname === "youtube.com") {
|
if (url.hostname === "www.youtube.com" || url.hostname === "youtube.com") {
|
||||||
// Extract the video ID from the URL params
|
// Extract the video ID from the URL params
|
||||||
@@ -11,11 +12,28 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||||||
redirectUrl: `https://www.youtube-nocookie.com/embed/${videoId}?rel=0` + (timecode ? "&start=" + timecode : "")
|
redirectUrl: `https://www.youtube-nocookie.com/embed/${videoId}?rel=0` + (timecode ? "&start=" + timecode : "")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
} else if (url.hostname === "github.com") {
|
||||||
|
const GOTHUB = "gothub.lunar.icu";
|
||||||
|
if (details.originUrl === undefined) { // entered in the address bar
|
||||||
|
return
|
||||||
|
}
|
||||||
|
origin = new URL(details.originUrl).hostname;
|
||||||
|
if (origin === GOTHUB || origin === "github.com") { // click within gothub or github page
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// click from everywhere else
|
||||||
|
path = url.pathname.split("/");
|
||||||
|
org = path[1];
|
||||||
|
repo = path[2];
|
||||||
|
return {
|
||||||
|
redirectUrl: `https://${GOTHUB}/${org}/${repo}`
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ urls: [
|
{ urls: [
|
||||||
"*://www.youtube.com/*",
|
"*://www.youtube.com/*",
|
||||||
"*://youtube.com/*"
|
"*://youtube.com/*",
|
||||||
|
"*://github.com/*",
|
||||||
]},
|
]},
|
||||||
["blocking"]
|
["blocking"]
|
||||||
);
|
);
|
||||||
|
|||||||
BIN
icon.png
BIN
icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 4.3 KiB |
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "YouTube force embed",
|
"name": "Desenshitifier",
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"description": "Rewrites YouTube URLs to embedded format.",
|
"description": "Rewrites YouTube URLs to embedded format.\nOpen Github links with Gothub",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
|
|||||||
Reference in New Issue
Block a user