Skip to content

Commit

Permalink
Improve Youtube VR stereo video detection (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Mar 31, 2020
1 parent b52ff39 commit 989a29e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/src/main/assets/web_extensions/webcompat_youtube/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class YoutubeExtension {
this.retry("overrideQuality", () => this.overrideQuality());
}

is360(text) {
return text.includes('360');
}

isStereo(text) {
const words = text.toLowerCase().split(/\s+|\./);
return words.includes('stereo') || words.includes('3d') || words.includes('vr');
}

// Automatically select a video projection if needed
overrideVideoProjection() {
if (!this.isWatchingPage()) {
Expand All @@ -87,9 +96,9 @@ class YoutubeExtension {
document.querySelector(YT_SELECTORS.disclaimer),
document.querySelector(YT_SELECTORS.embedTitle)
];
const is360 = targets.some((node) => node && node.textContent.includes('360'));
const is360 = targets.some((node) => node && this.is360(node.textContent));
if (is360) {
const stereo = targets.some((node) => node && node.textContent.toLowerCase().includes('stereo'));
const stereo = targets.some((node) => node && this.isStereo(node.textContent));
qs.set('mozVideoProjection', stereo ? '360s_auto' : '360_auto');
this.updateURL(qs);
this.updateVideoStyle();
Expand Down

0 comments on commit 989a29e

Please sign in to comment.