v1.3.3-beta/HBO support

This commit is contained in:
Ayushya Amitabh
2020-06-05 00:42:47 -04:00
parent be3c74d37d
commit 7170568dbe
7 changed files with 56 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-crx", "name": "watch-party-crx",
"version": "1.3.2", "version": "1.3.3",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@giphy/js-fetch-api": "^1.5.8", "@giphy/js-fetch-api": "^1.5.8",
+3 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "Watch Party", "name": "Watch Party",
"short_name": "WP", "short_name": "WP",
"version": "1.3.2", "version": "1.3.3",
"description": "Watch streamed content together.", "description": "Watch streamed content together.",
"background": { "background": {
"page": "popup.html" "page": "popup.html"
@@ -13,6 +13,7 @@
"https://*.disneyplus.com/*", "https://*.disneyplus.com/*",
"https://*.youtube.com/*", "https://*.youtube.com/*",
"https://play.hbonow.com/*", "https://play.hbonow.com/*",
"https://play.hbomax.com/*",
"http://localhost/*" "http://localhost/*"
], ],
"content_security_policy": "script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'", "content_security_policy": "script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'",
@@ -48,7 +49,7 @@
"css": ["/static/css/app.css"] "css": ["/static/css/app.css"]
}, },
{ {
"matches": ["https://play.hbonow.com/*"], "matches": ["https://play.hbonow.com/*", "https://play.hbomax.com/*"],
"run_at": "document_idle", "run_at": "document_idle",
"js": ["/static/js/content.js"], "js": ["/static/js/content.js"],
"css": ["/static/css/app.css"] "css": ["/static/css/app.css"]
+2
View File
@@ -17,6 +17,7 @@ export const PLAYER_SOURCE = {
DISNEY: 'https://www.disneyplus.', DISNEY: 'https://www.disneyplus.',
YOUTUBE: 'https://www.youtube.', YOUTUBE: 'https://www.youtube.',
HBONOW: 'https://play.hbonow.', HBONOW: 'https://play.hbonow.',
HBOMAX: 'https://play.hbomax.',
LOCAL: 'http://localhost', LOCAL: 'http://localhost',
}; };
@@ -28,6 +29,7 @@ export const getPlayerSource = () => {
if (HREF.startsWith(PLAYER_SOURCE.DISNEY)) return PLAYER_SOURCE.DISNEY; if (HREF.startsWith(PLAYER_SOURCE.DISNEY)) return PLAYER_SOURCE.DISNEY;
if (HREF.startsWith(PLAYER_SOURCE.YOUTUBE)) return PLAYER_SOURCE.YOUTUBE; if (HREF.startsWith(PLAYER_SOURCE.YOUTUBE)) return PLAYER_SOURCE.YOUTUBE;
if (HREF.startsWith(PLAYER_SOURCE.HBONOW)) return PLAYER_SOURCE.HBONOW; if (HREF.startsWith(PLAYER_SOURCE.HBONOW)) return PLAYER_SOURCE.HBONOW;
if (HREF.startsWith(PLAYER_SOURCE.HBOMAX)) return PLAYER_SOURCE.HBOMAX;
if (HREF.startsWith(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL; if (HREF.startsWith(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL;
}; };
+47 -2
View File
@@ -81,6 +81,10 @@ export default class VideoListener {
case PLAYER_SOURCE.HULU: case PLAYER_SOURCE.HULU:
window.postMessage({ type: 'SEEK', time: serverPlayer.time }, '*'); window.postMessage({ type: 'SEEK', time: serverPlayer.time }, '*');
break; break;
case PLAYER_SOURCE.HBOMAX:
case PLAYER_SOURCE.HBONOW:
this.video.element.currentTime = serverPlayer.time;
break;
default: default:
break; break;
} }
@@ -90,7 +94,9 @@ export default class VideoListener {
case PLAYER_STATUS.PAUSED: case PLAYER_STATUS.PAUSED:
if ( if (
PLAYER_SOURCE.HULU === this.video.source || PLAYER_SOURCE.HULU === this.video.source ||
PLAYER_SOURCE.NETFLIX === this.video.source PLAYER_SOURCE.NETFLIX === this.video.source ||
PLAYER_SOURCE.HBOMAX === this.video.source ||
PLAYER_SOURCE.HBONOW === this.video.source
) )
window.postMessage({ type: 'PAUSE', time: serverPlayer.time }, '*'); window.postMessage({ type: 'PAUSE', time: serverPlayer.time }, '*');
else await this.video.element.pause(); else await this.video.element.pause();
@@ -98,7 +104,9 @@ export default class VideoListener {
case PLAYER_STATUS.PLAYING: case PLAYER_STATUS.PLAYING:
if ( if (
PLAYER_SOURCE.HULU === this.video.source || PLAYER_SOURCE.HULU === this.video.source ||
PLAYER_SOURCE.NETFLIX === this.video.source PLAYER_SOURCE.NETFLIX === this.video.source ||
PLAYER_SOURCE.HBOMAX === this.video.source ||
PLAYER_SOURCE.HBONOW === this.video.source
) )
window.postMessage({ type: 'PLAY', time: serverPlayer.time }, '*'); window.postMessage({ type: 'PLAY', time: serverPlayer.time }, '*');
else else
@@ -162,6 +170,11 @@ export default class VideoListener {
const yshow = document.querySelector('h1.title').innerText; const yshow = document.querySelector('h1.title').innerText;
const yepisode = document.querySelector('yt-formatted-string.super-title').innerText; const yepisode = document.querySelector('yt-formatted-string.super-title').innerText;
return yshow === '' && yepisode === '' ? null : yshow + '\n' + yepisode; return yshow === '' && yepisode === '' ? null : yshow + '\n' + yepisode;
case PLAYER_SOURCE.HBOMAX:
case PLAYER_SOURCE.HBONOW:
const hboshow = document.querySelector('#hboUpperTitle').innerText;
const hboepisode = document.querySelector('#hboLowerTitle').innerText;
return hboshow === '' && hboepisode === '' ? null : hboshow + '\n' + hboepisode;
default: default:
break; break;
} }
@@ -285,6 +298,38 @@ export default class VideoListener {
); );
} }
break; break;
case PLAYER_SOURCE.HBOMAX:
case PLAYER_SOURCE.HBONOW:
const hboSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector('video.default')._dispNode;return e;},seekInteraction=function(e){if(e.source==window){if(e.data.type&&e.data.type==="PAUSE"){getVideoPlayer().pause();}if(e.data.type&&e.data.type==="PLAY"){getVideoPlayer().play();}e.data.type&&"teardown"==e.data.type&&(window.removeEventListener("message",seekInteraction,!1),window.seekScriptLoaded=!1)}};window.addEventListener("message",seekInteraction,!1);`;
const hboSeekInjectScript = document.createElement('script');
hboSeekInjectScript.text = hboSeekInject;
document.head.appendChild(hboSeekInjectScript);
const hboVideoElement = document.querySelector('video.default');
if (hboVideoElement) {
const bottomHalf =
hboVideoElement.parentNode.parentNode.parentNode.parentNode.parentNode.children[1];
bottomHalf.children[0].id = 'hboUpperTitle';
bottomHalf.children[1].id = 'hboLowerTitle';
this.firstTimeSync(hboVideoElement);
} else {
setInterval(
this.video.element
? null
: () => {
var hve = document.querySelector('video.default');
if (hve !== null && (this.video.element !== hve || this.video.element === null)) {
const bottomHalf =
hboVideoElement.parentNode.parentNode.parentNode.parentNode.parentNode
.children[1];
bottomHalf.children[0].id = 'hboUpperTitle';
bottomHalf.children[1].id = 'hboLowerTitle';
this.firstTimeSync(hve);
}
},
1000
);
}
break;
case PLAYER_SOURCE.LOCAL: case PLAYER_SOURCE.LOCAL:
const localVideoElement = document.getElementsByTagName('video')[0]; const localVideoElement = document.getElementsByTagName('video')[0];
if (localVideoElement) { if (localVideoElement) {
+1
View File
@@ -54,6 +54,7 @@ switch (getPlayerSource()) {
document.body.classList.add('youtube'); document.body.classList.add('youtube');
break; break;
case PLAYER_SOURCE.HBONOW: case PLAYER_SOURCE.HBONOW:
case PLAYER_SOURCE.HBOMAX:
document.body.classList.add('hbo'); document.body.classList.add('hbo');
break; break;
case PLAYER_SOURCE.LOCAL: case PLAYER_SOURCE.LOCAL:
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-api", "name": "watch-party-api",
"version": "1.3.2", "version": "1.3.3",
"description": "Cloud Functions for Watch Party", "description": "Cloud Functions for Watch Party",
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party", "name": "watch-party",
"version": "1.3.2", "version": "1.3.3",
"description": "Watch Party", "description": "Watch Party",
"scripts": { "scripts": {
"start": "firebase emulators:start", "start": "firebase emulators:start",