Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16e8b24fe4 | |||
| ecb68ee78b | |||
| fa27167f5c | |||
| 1d5377ad6d | |||
| 78d23a978d |
@@ -7,7 +7,7 @@ This is a Firefox Addon that redirect youtube URL to the embed version to have a
|
|||||||
* click on "Load Temporary Add-on…"
|
* click on "Load Temporary Add-on…"
|
||||||
* select "manifest.json" file
|
* select "manifest.json" file
|
||||||
|
|
||||||
## to have it in private navication
|
## to have it in private navigation
|
||||||
|
|
||||||
* go to "about:addons"
|
* go to "about:addons"
|
||||||
* select the extension
|
* select the extension
|
||||||
|
|||||||
@@ -1,21 +1,47 @@
|
|||||||
// Listen for web requests
|
|
||||||
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);
|
||||||
|
|
||||||
// Check if the URL is a YouTube 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
|
// Extract the video ID from the URL params
|
||||||
const videoId = url.searchParams.get("v");
|
const videoId = url.searchParams.get("v");
|
||||||
if (videoId) {
|
if (videoId) {
|
||||||
// Rewrite to the embedded URL format
|
// Rewrite to the embedded URL format, picking timecode if available
|
||||||
const embedUrl = `https://www.youtube.com/embed/${videoId}`;
|
const timecode = url.searchParams.get("t");
|
||||||
return { redirectUrl: embedUrl };
|
return {
|
||||||
|
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];
|
||||||
|
if (org === "login") { // OAuth2 path
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
redirectUrl: `https://${GOTHUB}${url.pathname}`
|
||||||
|
};
|
||||||
|
} else if (url.hostname === "www.reddit.com") {
|
||||||
|
url.hostname = "old.reddit.com"
|
||||||
|
return {
|
||||||
|
redirectUrl: url.toString()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ urls: [ "*://www.youtube.com/*",
|
{ urls: [
|
||||||
"*://youtube.com/*"] },
|
"*://www.youtube.com/*",
|
||||||
|
"*://youtube.com/*",
|
||||||
|
"*://github.com/*",
|
||||||
|
"*://www.reddit.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 URL Rewriter",
|
"name": "Desenshitifier",
|
||||||
"version": "1.0",
|
"version": "1.2",
|
||||||
"description": "Rewrites YouTube URLs to embedded format.",
|
"description": "Rewrites YouTube URLs to embedded format.\nOpen Github links with Gothub\nredirect reddit, www to old",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
|
|||||||
Reference in New Issue
Block a user