v1.3.3-beta/HBO support
This commit is contained in:
@@ -17,6 +17,7 @@ export const PLAYER_SOURCE = {
|
||||
DISNEY: 'https://www.disneyplus.',
|
||||
YOUTUBE: 'https://www.youtube.',
|
||||
HBONOW: 'https://play.hbonow.',
|
||||
HBOMAX: 'https://play.hbomax.',
|
||||
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.YOUTUBE)) return PLAYER_SOURCE.YOUTUBE;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ export default class VideoListener {
|
||||
case PLAYER_SOURCE.HULU:
|
||||
window.postMessage({ type: 'SEEK', time: serverPlayer.time }, '*');
|
||||
break;
|
||||
case PLAYER_SOURCE.HBOMAX:
|
||||
case PLAYER_SOURCE.HBONOW:
|
||||
this.video.element.currentTime = serverPlayer.time;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -90,7 +94,9 @@ export default class VideoListener {
|
||||
case PLAYER_STATUS.PAUSED:
|
||||
if (
|
||||
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 }, '*');
|
||||
else await this.video.element.pause();
|
||||
@@ -98,7 +104,9 @@ export default class VideoListener {
|
||||
case PLAYER_STATUS.PLAYING:
|
||||
if (
|
||||
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 }, '*');
|
||||
else
|
||||
@@ -162,6 +170,11 @@ export default class VideoListener {
|
||||
const yshow = document.querySelector('h1.title').innerText;
|
||||
const yepisode = document.querySelector('yt-formatted-string.super-title').innerText;
|
||||
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:
|
||||
break;
|
||||
}
|
||||
@@ -285,6 +298,38 @@ export default class VideoListener {
|
||||
);
|
||||
}
|
||||
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:
|
||||
const localVideoElement = document.getElementsByTagName('video')[0];
|
||||
if (localVideoElement) {
|
||||
|
||||
@@ -54,6 +54,7 @@ switch (getPlayerSource()) {
|
||||
document.body.classList.add('youtube');
|
||||
break;
|
||||
case PLAYER_SOURCE.HBONOW:
|
||||
case PLAYER_SOURCE.HBOMAX:
|
||||
document.body.classList.add('hbo');
|
||||
break;
|
||||
case PLAYER_SOURCE.LOCAL:
|
||||
|
||||
Reference in New Issue
Block a user