v1.2.0-beta/full hulu support and improved netflix
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
"https://*.netflix.com/*",
|
"https://*.netflix.com/*",
|
||||||
"https://*.amazon.com/*",
|
"https://*.amazon.com/*",
|
||||||
"https://*.disneyplus.com/*",
|
"https://*.disneyplus.com/*",
|
||||||
"https://*.youtube.com/*"
|
"https://*.youtube.com/*",
|
||||||
|
"https://play.hbonow.com/*"
|
||||||
],
|
],
|
||||||
"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'",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
@@ -44,6 +45,12 @@
|
|||||||
"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"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matches": ["https://play.hbonow.com/*"],
|
||||||
|
"run_at": "document_idle",
|
||||||
|
"js": ["/static/js/content.js"],
|
||||||
|
"css": ["/static/css/app.css"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"web_accessible_resources": ["android-icon-192x192.png"],
|
"web_accessible_resources": ["android-icon-192x192.png"],
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export const PLAYER_SOURCE = {
|
|||||||
HULU: 'https://www.hulu.',
|
HULU: 'https://www.hulu.',
|
||||||
DISNEY: 'https://www.disneyplus.',
|
DISNEY: 'https://www.disneyplus.',
|
||||||
YOUTUBE: 'https://www.youtube.',
|
YOUTUBE: 'https://www.youtube.',
|
||||||
|
HBONOW: 'https://play.hbonow.',
|
||||||
LOCAL: 'http://localhost',
|
LOCAL: 'http://localhost',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export const getPlayerSource = () => {
|
|||||||
if (HREF.startsWith(PLAYER_SOURCE.AMAZON)) return PLAYER_SOURCE.AMAZON;
|
if (HREF.startsWith(PLAYER_SOURCE.AMAZON)) return PLAYER_SOURCE.AMAZON;
|
||||||
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.LOCAL)) return PLAYER_SOURCE.LOCAL;
|
if (HREF.startsWith(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -29,9 +29,9 @@ import Create from './Create';
|
|||||||
import VideoListener from './VideoListener';
|
import VideoListener from './VideoListener';
|
||||||
|
|
||||||
const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq');
|
const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq');
|
||||||
const huluAlert = {
|
const alertMessage = {
|
||||||
name: '<alert>',
|
name: '<alert>',
|
||||||
text: 'Time sync is not available on Hulu yet.',
|
text: 'Functionality may be buggy, support on this site is in beta.',
|
||||||
time: '',
|
time: '',
|
||||||
uid: '<system>',
|
uid: '<system>',
|
||||||
};
|
};
|
||||||
@@ -216,8 +216,8 @@ export default class Chat extends Component {
|
|||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { admin, name, messages, newMessage, gif } = this.state;
|
const { admin, name, messages, newMessage, gif } = this.state;
|
||||||
if (getPlayerSource() === PLAYER_SOURCE.HULU && messages[0] !== huluAlert)
|
if (getPlayerSource() === PLAYER_SOURCE.HBONOW && messages[0] !== alertMessage)
|
||||||
messages.unshift(huluAlert);
|
messages.unshift(alertMessage);
|
||||||
return (
|
return (
|
||||||
<div className="party-chat-container">
|
<div className="party-chat-container">
|
||||||
<div className="party-chat-header">
|
<div className="party-chat-header">
|
||||||
|
|||||||
+20
-2
@@ -78,6 +78,9 @@ export default class VideoListener {
|
|||||||
case PLAYER_SOURCE.YOUTUBE:
|
case PLAYER_SOURCE.YOUTUBE:
|
||||||
this.video.element.currentTime = serverPlayer.time;
|
this.video.element.currentTime = serverPlayer.time;
|
||||||
break;
|
break;
|
||||||
|
case PLAYER_SOURCE.HULU:
|
||||||
|
window.postMessage({ type: 'SEEK', time: serverPlayer.time }, '*');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -85,9 +88,20 @@ export default class VideoListener {
|
|||||||
// TOGGLE PLAYER STATUS
|
// TOGGLE PLAYER STATUS
|
||||||
switch (serverPlayer.status) {
|
switch (serverPlayer.status) {
|
||||||
case PLAYER_STATUS.PAUSED:
|
case PLAYER_STATUS.PAUSED:
|
||||||
await this.video.element.pause();
|
if (
|
||||||
|
PLAYER_SOURCE.HULU === this.video.source ||
|
||||||
|
PLAYER_SOURCE.NETFLIX === this.video.source
|
||||||
|
)
|
||||||
|
window.postMessage({ type: 'PAUSE', time: serverPlayer.time }, '*');
|
||||||
|
else await this.video.element.pause();
|
||||||
break;
|
break;
|
||||||
case PLAYER_STATUS.PLAYING:
|
case PLAYER_STATUS.PLAYING:
|
||||||
|
if (
|
||||||
|
PLAYER_SOURCE.HULU === this.video.source ||
|
||||||
|
PLAYER_SOURCE.NETFLIX === this.video.source
|
||||||
|
)
|
||||||
|
window.postMessage({ type: 'PLAY', time: serverPlayer.time }, '*');
|
||||||
|
else
|
||||||
await this.video.element
|
await this.video.element
|
||||||
.play()
|
.play()
|
||||||
.catch((err) => console.error('WatchParty erred when syncing play.'));
|
.catch((err) => console.error('WatchParty erred when syncing play.'));
|
||||||
@@ -186,7 +200,7 @@ export default class VideoListener {
|
|||||||
this.updateStatus({ source: getPlayerSource(), showName: await this.getShowName() });
|
this.updateStatus({ source: getPlayerSource(), showName: await this.getShowName() });
|
||||||
switch (this.video.source) {
|
switch (this.video.source) {
|
||||||
case PLAYER_SOURCE.NETFLIX:
|
case PLAYER_SOURCE.NETFLIX:
|
||||||
const seekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=window.netflix.appContext.state.playerApp.getAPI().videoPlayer,t=e.getAllPlayerSessionIds()[0];return e.getVideoPlayerBySessionId(t)},seekInteraction=function(e){if(e.source==window){if(e.data.type&&"SEEK"==e.data.type){getVideoPlayer().pause();getVideoPlayer().seek(e.data.time);}e.data.type&&"teardown"==e.data.type&&(window.removeEventListener("message",seekInteraction,!1),window.seekScriptLoaded=!1)}};window.addEventListener("message",seekInteraction,!1);`;
|
const seekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=window.netflix.appContext.state.playerApp.getAPI().videoPlayer,t=e.getAllPlayerSessionIds()[0];return e.getVideoPlayerBySessionId(t)},seekInteraction=function(e){if(e.source==window){if(e.data.type&&"SEEK"==e.data.type){getVideoPlayer().pause();getVideoPlayer().seek(e.data.time);}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 seekInjectScript = document.createElement('script');
|
const seekInjectScript = document.createElement('script');
|
||||||
seekInjectScript.text = seekInject;
|
seekInjectScript.text = seekInject;
|
||||||
document.head.appendChild(seekInjectScript);
|
document.head.appendChild(seekInjectScript);
|
||||||
@@ -217,6 +231,10 @@ export default class VideoListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PLAYER_SOURCE.HULU:
|
case PLAYER_SOURCE.HULU:
|
||||||
|
const huluSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.getElementsByClassName('content-video-player')[0].__HuluDashPlayer__;return e;},seekInteraction=function(e){if(e.source==window){if(e.data.type&&"SEEK"==e.data.type){getVideoPlayer().seek(e.data.time,e.data.time);}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 huluSeekInjectScript = document.createElement('script');
|
||||||
|
huluSeekInjectScript.text = huluSeekInject;
|
||||||
|
document.head.appendChild(huluSeekInjectScript);
|
||||||
const videoElement = document.getElementsByClassName('content-video-player')[0];
|
const videoElement = document.getElementsByClassName('content-video-player')[0];
|
||||||
if (videoElement) {
|
if (videoElement) {
|
||||||
this.firstTimeSync(videoElement);
|
this.firstTimeSync(videoElement);
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,8 @@ body.hulu.visible .Player__container,/* HULU */
|
|||||||
body.amazon-prime.visible #dv-web-player.dv-player-fullscreen, /* AMAZON PRIME */
|
body.amazon-prime.visible #dv-web-player.dv-player-fullscreen, /* AMAZON PRIME */
|
||||||
body.disney.visible #hudson-wrapper, /* DISNEY */
|
body.disney.visible #hudson-wrapper, /* DISNEY */
|
||||||
body.youtube.visible #content.ytd-app, /* YOUTUBE */
|
body.youtube.visible #content.ytd-app, /* YOUTUBE */
|
||||||
body.youtube.visible #masthead-container /* YOUTUBE HEADER */ {
|
body.youtube.visible #masthead-container, /* YOUTUBE HEADER */
|
||||||
|
body.hbo.visible video.default {
|
||||||
max-width: var(--body-width) !important;
|
max-width: var(--body-width) !important;
|
||||||
}
|
}
|
||||||
/* HULU MINIMIZED VIDEO */
|
/* HULU MINIMIZED VIDEO */
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ switch (getPlayerSource()) {
|
|||||||
case PLAYER_SOURCE.YOUTUBE:
|
case PLAYER_SOURCE.YOUTUBE:
|
||||||
document.body.classList.add('youtube');
|
document.body.classList.add('youtube');
|
||||||
break;
|
break;
|
||||||
|
case PLAYER_SOURCE.HBONOW:
|
||||||
|
document.body.classList.add('hbo');
|
||||||
|
break;
|
||||||
case PLAYER_SOURCE.LOCAL:
|
case PLAYER_SOURCE.LOCAL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user