This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Improve youtube layout #2509
Merged
Merged
Improve youtube layout #2509
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{ | ||
"744723238cc3c00582d7ff9e8ece83e6503a3926d8c07491672d5da3634be41e1d41580dd3694b663c0d0a5e64280a2b411a1346e6ed0d53d694835781cf6436": "Mozilla/5.0 (X11; Linux x86_64; rv:69) Gecko/20100101 Firefox/69.0", | ||
"ae0755740e4354ac67025056e775ad06d8a529ae4f37244fbb02d72199e2c780311e47aa9895079b980ec4bfa676f1f39c4ab41ea995c524e52bde9a73623da2": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21", | ||
"e6137b4c2f49a3917c2c90a50fb270a5eebb962f2c72344ae2e29e321bb21891e5ca4fec06cae78e14f4a8510473e934234e9ec3f60e8415f5f6da754c55b9b1": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
const CUSTOM_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21'; | ||
const CUSTOM_USER_AGENT = 'Mozilla/5.0 (Linux; Android 7.1.1; Quest) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/7.0.13.186866463 SamsungBrowser/4.0 Chrome/77.0.3865.126 Mobile VR Safari/537.36'; | ||
const targetUrls = [ | ||
"https://*.youtube.com/*", | ||
"https://*.youtube-nocookie.com/*" | ||
]; | ||
Comment on lines
+1
to
5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish there was a way to work around the iframe issue since the whole reason the over ride list was added was to avoid running JS every time for every request. |
||
|
||
/** | ||
* 1. Disable YouTube's Polymer layout (which makes YouTube very slow in non-Chrome browsers) | ||
* via a query-string parameter in the URL. | ||
* 2. Rewrite YouTube URLs from `m.youtube.com` -> `youtube.com` (to avoid serving YouTube's | ||
* video pages intended for mobile phones, as linked from Google search results). | ||
*/ | ||
function redirectUrl(req) { | ||
let redirect = false; | ||
const url = new URL(req.url); | ||
if (url.host.startsWith("m.")) { | ||
url.host = url.host.replace("m.", "www."); | ||
redirect = true; | ||
} | ||
if (!url.searchParams.get("disable_polymer")) { | ||
url.searchParams.set("disable_polymer", "1"); | ||
redirect = true; | ||
} | ||
if (!redirect) { | ||
return null; | ||
} | ||
return { redirectUrl: url.toString() }; | ||
} | ||
|
||
/** | ||
* Override UA. This is required to get the equirectangular video formats from Youtube. | ||
* Otherwise youtube uses custom 360 controls. | ||
|
@@ -40,12 +17,6 @@ function overrideUA(req) { | |
return { requestHeaders: req.requestHeaders }; | ||
} | ||
|
||
browser.webRequest.onBeforeRequest.addListener( | ||
redirectUrl, | ||
{ urls: targetUrls, types: ["main_frame"]}, | ||
["blocking"] | ||
); | ||
|
||
browser.webRequest.onBeforeSendHeaders.addListener( | ||
overrideUA, | ||
{ urls: targetUrls }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this last one for vimeo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was for PH? I don't remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's vimeo.com.