v1.6.2/release

-website update
-dynamic showName and video element
-time update on playing
This commit is contained in:
2020-08-14 00:36:44 -04:00
parent 3c4fffe598
commit aaf2506f78
14 changed files with 582 additions and 338 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-crx", "name": "watch-party-crx",
"version": "1.6.0", "version": "1.6.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-crx", "name": "watch-party-crx",
"version": "1.6.1", "version": "1.6.2",
"private": true, "private": true,
"dependencies": {}, "dependencies": {},
"scripts": { "scripts": {
+1 -1
View File
@@ -12,7 +12,7 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
/* global chrome */ /* global chrome */
/* global firebase */ /* global firebase */
const APP_VERSION = "1.6.1"; const APP_VERSION = "1.6.2";
const APP_VERSION_STRING = APP_VERSION.replace(/\./g, ""); const APP_VERSION_STRING = APP_VERSION.replace(/\./g, "");
const firebaseConfig = { const firebaseConfig = {
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "Watch Party", "name": "Watch Party",
"short_name": "WP", "short_name": "WP",
"version": "1.6.1", "version": "1.6.2",
"description": "Watch streamed content together.", "description": "Watch streamed content together.",
"background": { "background": {
"page": "background.html" "page": "background.html"
+60 -38
View File
@@ -9,27 +9,33 @@ ALL CONTENT ON WATCH PARTY'S WEBSITE OR IN WATCH PARTY'S CHROME EXTENSION APP, U
CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION. COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
************************************************************************/ ************************************************************************/
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from "react";
import Router from 'route-lite'; import Router from "route-lite";
import { Fab, createMuiTheme, ThemeProvider, Snackbar, Tooltip } from '@material-ui/core'; import {
import Create from './Create'; Fab,
import Loading from './Loading'; createMuiTheme,
import firebase from 'firebase/app'; ThemeProvider,
import 'firebase/firestore'; Snackbar,
import Inactive from './Inactive'; Tooltip,
import { getUserUid, getPlayerSource, PLAYER_SOURCE } from './Api'; } from "@material-ui/core";
import Create from "./Create";
import Loading from "./Loading";
import firebase from "firebase/app";
import "firebase/firestore";
import Inactive from "./Inactive";
import { getUserUid, getPlayerSource, PLAYER_SOURCE } from "./Api";
const APP_VERSION = '1.6.1'; const APP_VERSION = "1.6.2";
const APP_VERSION_STRING = APP_VERSION.replace(/\./g, ''); const APP_VERSION_STRING = APP_VERSION.replace(/\./g, "");
const darkTheme = createMuiTheme({ const darkTheme = createMuiTheme({
palette: { palette: {
type: 'dark', type: "dark",
primary: { primary: {
main: '#FF0000', main: "#FF0000",
}, },
secondary: { secondary: {
main: '#c0f300', main: "#c0f300",
}, },
}, },
}); });
@@ -42,32 +48,41 @@ const Routes = (props) => (
const resetResize = () => { const resetResize = () => {
const checkedX = 400; const checkedX = 400;
document.documentElement.style.setProperty('--party-width', `${checkedX}px`); document.documentElement.style.setProperty("--party-width", `${checkedX}px`);
document.documentElement.style.setProperty('--neg-party-width', `-${checkedX}px`); document.documentElement.style.setProperty(
"--neg-party-width",
`-${checkedX}px`
);
}; };
const doResize = (ev) => { const doResize = (ev) => {
const checkedX = const checkedX =
window.innerWidth - window.innerWidth -
Math.min(window.innerWidth - 300, Math.max(window.innerWidth * 0.5, ev.clientX)); Math.min(
document.documentElement.style.setProperty('--party-width', `${checkedX}px`); window.innerWidth - 300,
document.documentElement.style.setProperty('--neg-party-width', `-${checkedX}px`); Math.max(window.innerWidth * 0.5, ev.clientX)
);
document.documentElement.style.setProperty("--party-width", `${checkedX}px`);
document.documentElement.style.setProperty(
"--neg-party-width",
`-${checkedX}px`
);
}; };
const stopResize = (ev) => { const stopResize = (ev) => {
document.documentElement.removeEventListener('mousemove', doResize, false); document.documentElement.removeEventListener("mousemove", doResize, false);
document.documentElement.removeEventListener('mouseup', stopResize, false); document.documentElement.removeEventListener("mouseup", stopResize, false);
}; };
const startResize = (ev) => { const startResize = (ev) => {
document.documentElement.addEventListener('mousemove', doResize, false); document.documentElement.addEventListener("mousemove", doResize, false);
document.documentElement.addEventListener('mouseup', stopResize, false); document.documentElement.addEventListener("mouseup", stopResize, false);
}; };
const App = () => { const App = () => {
const closedNotification = { open: false, message: '' }; const closedNotification = { open: false, message: "" };
const [status, setStatus] = useState({ active: false, message: '' }); const [status, setStatus] = useState({ active: false, message: "" });
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [notification, setNotification] = useState(closedNotification); const [notification, setNotification] = useState(closedNotification);
@@ -79,8 +94,8 @@ const App = () => {
getUserUid(); getUserUid();
firebase firebase
.firestore() .firestore()
.collection('server') .collection("server")
.doc('status') .doc("status")
.onSnapshot((statusSnap) => { .onSnapshot((statusSnap) => {
setStatus(statusSnap.data()); setStatus(statusSnap.data());
setLoading(false); setLoading(false);
@@ -88,18 +103,19 @@ const App = () => {
}, []); }, []);
// HANDLE VISIBILITY STYLING // HANDLE VISIBILITY STYLING
const PartyRoutesWrapper = document.getElementById('party-routes-wrapper'); const PartyRoutesWrapper = document.getElementById("party-routes-wrapper");
if (visible) { if (visible) {
document.body.classList.add('visible'); document.body.classList.add("visible");
PartyRoutesWrapper && PartyRoutesWrapper.classList.add('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.add("visible");
if ( if (
!hasAttached && !hasAttached &&
(getPlayerSource() === PLAYER_SOURCE.HBOMAX || getPlayerSource() === PLAYER_SOURCE.HBONOW) (getPlayerSource() === PLAYER_SOURCE.HBOMAX ||
getPlayerSource() === PLAYER_SOURCE.HBONOW)
) { ) {
document.addEventListener( document.addEventListener(
'mousedown', "mousedown",
function (ev) { function (ev) {
if (document.body.querySelector('body.visible')) { if (document.body.querySelector("body.visible")) {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
ev.stopImmediatePropagation(); ev.stopImmediatePropagation();
@@ -110,8 +126,8 @@ const App = () => {
hasAttached = true; hasAttached = true;
} }
} else { } else {
document.body.classList.remove('visible'); document.body.classList.remove("visible");
PartyRoutesWrapper && PartyRoutesWrapper.classList.remove('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.remove("visible");
} }
// HANDLE FULLSCREEN EVENT // HANDLE FULLSCREEN EVENT
@@ -123,7 +139,7 @@ const App = () => {
<ThemeProvider theme={darkTheme}> <ThemeProvider theme={darkTheme}>
<Snackbar <Snackbar
className="party-notification-container" className="party-notification-container"
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
open={notification.open} open={notification.open}
onClose={() => setNotification(closedNotification)} onClose={() => setNotification(closedNotification)}
message={notification.message} message={notification.message}
@@ -136,12 +152,17 @@ const App = () => {
title="Resize Sidebar / Double Click To Reset" title="Resize Sidebar / Double Click To Reset"
aria-label="Resize Sidebar / Double Click To Reset" aria-label="Resize Sidebar / Double Click To Reset"
> >
<div onDoubleClick={resetResize} onMouseDown={startResize} id="party-width-dragger"> <div
onDoubleClick={resetResize}
onMouseDown={startResize}
id="party-width-dragger"
>
|| ||
</div> </div>
</Tooltip> </Tooltip>
{loading && <Loading />} {loading && <Loading />}
{status[APP_VERSION_STRING] && status[APP_VERSION_STRING].active === true ? ( {status[APP_VERSION_STRING] &&
status[APP_VERSION_STRING].active === true ? (
<Routes <Routes
updateLoading={setLoading} updateLoading={setLoading}
notify={(message) => setNotification({ open: true, message })} notify={(message) => setNotification({ open: true, message })}
@@ -149,6 +170,7 @@ const App = () => {
appVersionString={APP_VERSION_STRING} appVersionString={APP_VERSION_STRING}
status={status[APP_VERSION_STRING]} status={status[APP_VERSION_STRING]}
selectors={status.selectors} selectors={status.selectors}
nameSelectors={status.nameSelectors}
/> />
) : ( ) : (
<Inactive <Inactive
+213 -115
View File
@@ -10,7 +10,7 @@ CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION. COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
************************************************************************/ ************************************************************************/
/*global chrome */ /*global chrome */
import React, { Component } from 'react'; import React, { Component } from "react";
import { import {
Typography, Typography,
TextField, TextField,
@@ -31,8 +31,8 @@ import {
Paper, Paper,
Grid, Grid,
Slider, Slider,
} from '@material-ui/core'; } from "@material-ui/core";
import Thread from './Thread'; import Thread from "./Thread";
import { import {
SendMessageApi, SendMessageApi,
LeaveRoomApi, LeaveRoomApi,
@@ -46,7 +46,7 @@ import {
UpdateAdminOnly, UpdateAdminOnly,
scrollThread, scrollThread,
removeLocalData, removeLocalData,
} from './Api'; } from "./Api";
import { import {
Send, Send,
ExitToApp as Exit, ExitToApp as Exit,
@@ -68,21 +68,21 @@ import {
VolumeDown, VolumeDown,
VolumeUp, VolumeUp,
CancelRounded, CancelRounded,
} from '@material-ui/icons'; } from "@material-ui/icons";
import Create from './Create'; import Create from "./Create";
import { goTo } from 'route-lite'; import { goTo } from "route-lite";
import CallManager from './CallManager'; import CallManager from "./CallManager";
import VideoListener from './VideoListener'; import VideoListener from "./VideoListener";
import ReactGiphySearchbox from 'react-giphy-searchbox'; import ReactGiphySearchbox from "react-giphy-searchbox";
// const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq'); // const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq');
export default class Chat extends Component { export default class Chat extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
name: '', name: "",
messages: [], messages: [],
newMessage: '', newMessage: "",
admin: null, admin: null,
adminOnly: false, adminOnly: false,
adminModeUpdate: false, adminModeUpdate: false,
@@ -94,10 +94,14 @@ export default class Chat extends Component {
callActionPending: false, callActionPending: false,
menuPopover: true, menuPopover: true,
allowChatNotification: allowChatNotification:
LocalData().allowChatNotification !== undefined ? LocalData().allowChatNotification : true, LocalData().allowChatNotification !== undefined
? LocalData().allowChatNotification
: true,
isFullscreen: document.fullscreen, isFullscreen: document.fullscreen,
allowAutoRejoin: allowAutoRejoin:
LocalData().allowAutoRejoin !== undefined ? LocalData().allowAutoRejoin : true, LocalData().allowAutoRejoin !== undefined
? LocalData().allowAutoRejoin
: true,
replyTo: null, replyTo: null,
sendingMessages: [], sendingMessages: [],
volumes: {}, volumes: {},
@@ -117,17 +121,27 @@ export default class Chat extends Component {
this.callEventListener = this.callEventListener.bind(this); this.callEventListener = this.callEventListener.bind(this);
this.sendMessageInvoker = this.sendMessageInvoker.bind(this); this.sendMessageInvoker = this.sendMessageInvoker.bind(this);
this.videoEventListener = this.videoEventListener.bind(this); this.videoEventListener = this.videoEventListener.bind(this);
this.mVideoListener = new VideoListener(this.videoEventListener, props.selectors); this.mVideoListener = new VideoListener(
this.videoEventListener,
props.selectors,
props.nameSelectors
);
this.updateAllowAutoRejoin = this.updateAllowAutoRejoin.bind(this); this.updateAllowAutoRejoin = this.updateAllowAutoRejoin.bind(this);
this.updateAllowChatNotification = this.updateAllowChatNotification.bind(this); this.updateAllowChatNotification = this.updateAllowChatNotification.bind(
this.mCallManager = new CallManager(this.callEventListener, this.props.notify); this
);
this.mCallManager = new CallManager(
this.callEventListener,
this.props.notify
);
} }
componentDidMount() { componentDidMount() {
// EVENT CAPTURE FOR ENTER TO SEND // EVENT CAPTURE FOR ENTER TO SEND
window.onkeypress = (ev) => { window.onkeypress = (ev) => {
if (ev.code === 'Enter') { if (ev.code === "Enter") {
if (ev.target === document.getElementById('chat-message-box-input')) { if (ev.target === document.getElementById("chat-message-box-input")) {
if (ev.shiftKey === false && this.state.gif === true) ev.preventDefault(); if (ev.shiftKey === false && this.state.gif === true)
ev.preventDefault();
if (ev.shiftKey === false && this.state.gif === false) { if (ev.shiftKey === false && this.state.gif === false) {
ev.preventDefault(); ev.preventDefault();
this.sendMessageInvoker(); this.sendMessageInvoker();
@@ -137,12 +151,15 @@ export default class Chat extends Component {
}; };
// FULLSCREEN LISTENER // FULLSCREEN LISTENER
document.addEventListener('fullscreenchange', (ev) => { document.addEventListener("fullscreenchange", (ev) => {
this.setState({ isFullscreen: document.fullscreen }); this.setState({ isFullscreen: document.fullscreen });
}); });
// ACTIVE TRACKER // ACTIVE TRACKER
if (LocalData().allowAutoRejoin === undefined || LocalData().allowAutoRejoin === null) { if (
LocalData().allowAutoRejoin === undefined ||
LocalData().allowAutoRejoin === null
) {
updateLocalData({ allowAutoRejoin: this.state.allowAutoRejoin }); updateLocalData({ allowAutoRejoin: this.state.allowAutoRejoin });
} }
if (this.state.allowAutoRejoin === true) { if (this.state.allowAutoRejoin === true) {
@@ -161,14 +178,14 @@ export default class Chat extends Component {
this.port = chrome.runtime.connect({ name: LocalData().partyName }); this.port = chrome.runtime.connect({ name: LocalData().partyName });
// Initialize listener // Initialize listener
this.port.postMessage({ this.port.postMessage({
type: 'INIT', type: "INIT",
roomId: LocalData().partyName, roomId: LocalData().partyName,
roomPin: LocalData().partyPin, roomPin: LocalData().partyPin,
}); });
// Listener // Listener
this.port.onMessage.addListener((response) => { this.port.onMessage.addListener((response) => {
if (response.isError === true) { if (response.isError === true) {
this.props.notify('Uh oh. Got lost from the party.'); this.props.notify("Uh oh. Got lost from the party.");
goTo(Create, this.props); goTo(Create, this.props);
return; return;
} }
@@ -178,13 +195,21 @@ export default class Chat extends Component {
} }
// IF CHAT IS HIDDEN AND ALLOWS NOTIFICATION // IF CHAT IS HIDDEN AND ALLOWS NOTIFICATION
if (!document.querySelector('body.visible') && this.state.allowChatNotification === true) { if (
if (response.messages && response.messages.length !== this.state.messages.length) { !document.querySelector("body.visible") &&
this.state.allowChatNotification === true
) {
if (
response.messages &&
response.messages.length !== this.state.messages.length
) {
const lastMessage = response.messages[response.messages.length - 1]; const lastMessage = response.messages[response.messages.length - 1];
if (lastMessage.uid !== '<system>') { if (lastMessage.uid !== "<system>") {
this.props.notify( this.props.notify(
`${lastMessage.name}${ `${lastMessage.name}${
lastMessage.type === 'giphy' ? ' sent a gif.' : ': ' + lastMessage.text lastMessage.type === "giphy"
? " sent a gif."
: ": " + lastMessage.text
}` }`
); );
} }
@@ -200,12 +225,26 @@ export default class Chat extends Component {
// GIPHY IPC // GIPHY IPC
const giphyInject = `var giphySearchInteraction=function(e){if(e.source===window){const{data}=e;if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_SEARCH_GIF'){const giphyInput=document.querySelector('.giphy-search-form input');if(giphyInput){giphyInput.value=data.value;giphyInput.dispatchEvent(new Event('change',{bubbles:true}))}}}}};window.addEventListener("message",giphySearchInteraction);`; const giphyInject = `var giphySearchInteraction=function(e){if(e.source===window){const{data}=e;if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_SEARCH_GIF'){const giphyInput=document.querySelector('.giphy-search-form input');if(giphyInput){giphyInput.value=data.value;giphyInput.dispatchEvent(new Event('change',{bubbles:true}))}}}}};window.addEventListener("message",giphySearchInteraction);`;
const giphyInjectScript = document.createElement('script'); const giphyInjectScript = document.createElement("script");
giphyInjectScript.text = giphyInject; giphyInjectScript.text = giphyInject;
document.head.appendChild(giphyInjectScript); document.head.appendChild(giphyInjectScript);
// DONE WITH MOUNTING TASKS // DONE WITH MOUNTING TASKS
this.props.updateLoading(false); this.props.updateLoading(false);
setInterval(() => {
if (
this.state.player &&
this.state.player.time &&
this.state.player.status === PLAYER_STATUS.PLAYING
) {
const oldPlayer = this.state.player;
oldPlayer.time += 1;
this.setState({
player: oldPlayer,
});
}
}, 1000);
} }
componentWillUnmount() { componentWillUnmount() {
this.mVideoListener.end(); this.mVideoListener.end();
@@ -238,14 +277,14 @@ export default class Chat extends Component {
}).catch((err) => { }).catch((err) => {
this.props.updateLoading(false); this.props.updateLoading(false);
this.props.notify(err.message || err.statusText); this.props.notify(err.message || err.statusText);
console.error('Sync Party API error', err); console.error("Sync Party API error", err);
}); });
} else { } else {
this.mVideoListener.start(); this.mVideoListener.start();
} }
} }
endParty() { endParty() {
this.props.notify('Ending party...'); this.props.notify("Ending party...");
this.props.updateLoading(true); this.props.updateLoading(true);
const data = { const data = {
partyName: LocalData().partyName, partyName: LocalData().partyName,
@@ -259,20 +298,20 @@ export default class Chat extends Component {
); );
DeleteRoomApi(data) DeleteRoomApi(data)
.then((res) => { .then((res) => {
this.props.notify('Ended party'); this.props.notify("Ended party");
removeLocalData('partyPin'); removeLocalData("partyPin");
removeLocalData('partyName'); removeLocalData("partyName");
goTo(Create, this.props); goTo(Create, this.props);
this.props.updateLoading(false); this.props.updateLoading(false);
}) })
.catch((err) => { .catch((err) => {
this.props.updateLoading(false); this.props.updateLoading(false);
this.props.notify(err.message || err.statusText); this.props.notify(err.message || err.statusText);
console.error('End Party API error', err); console.error("End Party API error", err);
}); });
} }
leaveParty() { leaveParty() {
this.props.notify('Leaving party...'); this.props.notify("Leaving party...");
this.props.updateLoading(true); this.props.updateLoading(true);
const data = { const data = {
partyName: LocalData().partyName, partyName: LocalData().partyName,
@@ -287,28 +326,30 @@ export default class Chat extends Component {
); );
LeaveRoomApi(data) LeaveRoomApi(data)
.then((res) => { .then((res) => {
this.props.notify('Left party'); this.props.notify("Left party");
removeLocalData('partyPin'); removeLocalData("partyPin");
removeLocalData('partyName'); removeLocalData("partyName");
goTo(Create, this.props); goTo(Create, this.props);
this.props.updateLoading(false); this.props.updateLoading(false);
}) })
.catch((err) => { .catch((err) => {
this.props.updateLoading(false); this.props.updateLoading(false);
this.props.notify(err.message || err.statusText); this.props.notify(err.message || err.statusText);
console.error('End Party API error', err); console.error("End Party API error", err);
}); });
} }
shareParty() { shareParty() {
const el = document.createElement('textarea'); const el = document.createElement("textarea");
el.value = `Join my party on Watch Party!\nParty Name: ${LocalData().partyName}\nParty Pin: ${ el.value = `Join my party on Watch Party!\nParty Name: ${
LocalData().partyPin LocalData().partyName
}\n${window.location.href}\n---\nGet Watch Party at https:\\\\get.chromewatchparty.com`; }\nParty Pin: ${LocalData().partyPin}\n${
window.location.href
}\n---\nGet Watch Party at https:\\\\get.chromewatchparty.com`;
document.body.appendChild(el); document.body.appendChild(el);
el.select(); el.select();
document.execCommand('copy'); document.execCommand("copy");
document.body.removeChild(el); document.body.removeChild(el);
this.props.notify('Copied party invitation'); this.props.notify("Copied party invitation");
} }
sendMessage(message) { sendMessage(message) {
const { sendingMessages } = this.state; const { sendingMessages } = this.state;
@@ -319,9 +360,9 @@ export default class Chat extends Component {
uid: LocalData().userUid, uid: LocalData().userUid,
text: message, text: message,
time: new Date(), time: new Date(),
type: '', type: "",
}; };
if (this.state.gif === true) data.type = 'giphy'; if (this.state.gif === true) data.type = "giphy";
if (this.state.replyTo !== null) data.replyTo = this.state.replyTo.id; if (this.state.replyTo !== null) data.replyTo = this.state.replyTo.id;
sendingMessages.push(data); sendingMessages.push(data);
this.setState({ this.setState({
@@ -342,7 +383,7 @@ export default class Chat extends Component {
this.setState({ sendingMessages: sm }); this.setState({ sendingMessages: sm });
scrollThread(); scrollThread();
this.props.notify(err.message || err.statusText); this.props.notify(err.message || err.statusText);
console.error('Send Message API error', err); console.error("Send Message API error", err);
}); });
this.setState({ replyTo: null }); this.setState({ replyTo: null });
scrollThread(); scrollThread();
@@ -350,10 +391,10 @@ export default class Chat extends Component {
sendMessageInvoker(overrideMessage) { sendMessageInvoker(overrideMessage) {
if (overrideMessage) this.sendMessage(overrideMessage); if (overrideMessage) this.sendMessage(overrideMessage);
else { else {
const trim = this.state.newMessage.replace(/^\s+|\s+$/g, ''); const trim = this.state.newMessage.replace(/^\s+|\s+$/g, "");
if (trim !== '') this.sendMessage(trim); if (trim !== "") this.sendMessage(trim);
} }
this.setState({ newMessage: '' }); this.setState({ newMessage: "" });
} }
gifClick(iGif) { gifClick(iGif) {
this.sendMessageInvoker(iGif.images.original.url); this.sendMessageInvoker(iGif.images.original.url);
@@ -362,29 +403,29 @@ export default class Chat extends Component {
const { onCall, conference, admin, adminOnly } = this.state; const { onCall, conference, admin, adminOnly } = this.state;
if (window.navigator && onCall === false) { if (window.navigator && onCall === false) {
try { try {
const overlay = document.createElement('div'); const overlay = document.createElement("div");
overlay.innerHTML = ` overlay.innerHTML = `
<div id="mic-highlight"></div> <div id="mic-highlight"></div>
<h4 id="mic-text">Grant Mic Permission</h4> <h4 id="mic-text">Grant Mic Permission</h4>
`; `;
overlay.id = 'mic-permission-overlay'; overlay.id = "mic-permission-overlay";
document.body.appendChild(overlay); document.body.appendChild(overlay);
window.navigator window.navigator
.getUserMedia({ .getUserMedia({
audio: true, audio: true,
}) })
.then(() => { .then(() => {
document.getElementById('mic-permission-overlay').remove(); document.getElementById("mic-permission-overlay").remove();
this.mCallManager.toggleCall(onCall, conference, admin, adminOnly); this.mCallManager.toggleCall(onCall, conference, admin, adminOnly);
}) })
.catch(() => { .catch(() => {
document.getElementById('mic-permission-overlay').remove(); document.getElementById("mic-permission-overlay").remove();
this.props.notify( this.props.notify(
'Check your mic permission for this website. You can modify site permission by clicking on the lock icon in the top left.' "Check your mic permission for this website. You can modify site permission by clicking on the lock icon in the top left."
); );
}); });
} catch (err) { } catch (err) {
console.error('Handle Phone Call Error', err); console.error("Handle Phone Call Error", err);
} }
} else this.mCallManager.toggleCall(onCall, conference, admin, adminOnly); } else this.mCallManager.toggleCall(onCall, conference, admin, adminOnly);
} }
@@ -397,7 +438,9 @@ export default class Chat extends Component {
: new Date(t * 1000).toISOString().substr(14, 5); : new Date(t * 1000).toISOString().substr(14, 5);
} }
updateAllowChatNotification() { updateAllowChatNotification() {
updateLocalData({ allowChatNotification: !this.state.allowChatNotification }); updateLocalData({
allowChatNotification: !this.state.allowChatNotification,
});
this.setState({ allowChatNotification: !this.state.allowChatNotification }); this.setState({ allowChatNotification: !this.state.allowChatNotification });
} }
updateAllowAutoRejoin() { updateAllowAutoRejoin() {
@@ -418,7 +461,7 @@ export default class Chat extends Component {
adminOnly: !this.state.adminOnly, adminOnly: !this.state.adminOnly,
}).catch((err) => { }).catch((err) => {
this.props.notify(err.message || err.statusText); this.props.notify(err.message || err.statusText);
console.error('Update Admin Only API error', err); console.error("Update Admin Only API error", err);
}); });
} }
setReplyTo(message) { setReplyTo(message) {
@@ -430,7 +473,7 @@ export default class Chat extends Component {
getReplyToContent() { getReplyToContent() {
const { replyTo } = this.state; const { replyTo } = this.state;
if (replyTo) { if (replyTo) {
if (replyTo.type === 'giphy') { if (replyTo.type === "giphy") {
return <img alt="gif" src={replyTo.text} />; return <img alt="gif" src={replyTo.text} />;
} }
return ( return (
@@ -442,7 +485,7 @@ export default class Chat extends Component {
return null; return null;
} }
setVideoVolume(v, id) { setVideoVolume(v, id) {
const audioOuts = document.querySelectorAll('audio.vxt-audio'); const audioOuts = document.querySelectorAll("audio.vxt-audio");
if (audioOuts.length > 0) { if (audioOuts.length > 0) {
audioOuts.forEach((el) => { audioOuts.forEach((el) => {
if (el.id === `audio-${id}`) { if (el.id === `audio-${id}`) {
@@ -479,20 +522,23 @@ export default class Chat extends Component {
const alerts = [ const alerts = [
{ {
condition: () => condition: () =>
getPlayerSource() === PLAYER_SOURCE.HBOMAX || getPlayerSource() === PLAYER_SOURCE.HBONOW, getPlayerSource() === PLAYER_SOURCE.HBOMAX ||
message: 'Functionality may be buggy, HBO has a horrible design.', getPlayerSource() === PLAYER_SOURCE.HBONOW,
message: "Functionality may be buggy, HBO has a horrible design.",
}, },
{ {
condition: () => getPlayerSource() === PLAYER_SOURCE.GOOGLEPLAY, condition: () => getPlayerSource() === PLAYER_SOURCE.GOOGLEPLAY,
message: 'Functionality may be buggy, support on this site is in testing.', message:
"Functionality may be buggy, support on this site is in testing.",
}, },
{ {
condition: () => getPlayerSource() === PLAYER_SOURCE.CRUNCHYROLL, condition: () => getPlayerSource() === PLAYER_SOURCE.CRUNCHYROLL,
message: 'Functionality may be buggy, support on this site is in testing.', message:
"Functionality may be buggy, support on this site is in testing.",
}, },
{ {
condition: () => adminOnly, condition: () => adminOnly,
message: 'Party is currently in admin only mode.', message: "Party is currently in admin only mode.",
}, },
]; ];
return ( return (
@@ -519,7 +565,12 @@ export default class Chat extends Component {
> >
WATCH PARTY WATCH PARTY
</Typography> </Typography>
<Typography color="textPrimary" className="room-title" variant="h4" gutterBottom> <Typography
color="textPrimary"
className="room-title"
variant="h4"
gutterBottom
>
{name} {name}
</Typography> </Typography>
</div> </div>
@@ -528,9 +579,9 @@ export default class Chat extends Component {
<TextField <TextField
className="share-textbox" className="share-textbox"
label="Party Details" label="Party Details"
value={`Party Name: ${LocalData().partyName}\nParty Pin: ${LocalData().partyPin}\n${ value={`Party Name: ${LocalData().partyName}\nParty Pin: ${
window.location.href LocalData().partyPin
}`} }\n${window.location.href}`}
multiline multiline
rowsMax={2} rowsMax={2}
variant="outlined" variant="outlined"
@@ -557,13 +608,19 @@ export default class Chat extends Component {
color="secondary" color="secondary"
> >
<Button onClick={this.leaveParty} startIcon={<Exit />}> <Button onClick={this.leaveParty} startIcon={<Exit />}>
<Typography variant="caption" className="party-control-button-text"> <Typography
variant="caption"
className="party-control-button-text"
>
Leave Leave
</Typography> </Typography>
</Button> </Button>
{admin && ( {admin && (
<Button onClick={this.endParty} startIcon={<Delete />}> <Button onClick={this.endParty} startIcon={<Delete />}>
<Typography variant="caption" className="party-control-button-text"> <Typography
variant="caption"
className="party-control-button-text"
>
End End
</Typography> </Typography>
</Button> </Button>
@@ -576,15 +633,17 @@ export default class Chat extends Component {
checked={allowChatNotification} checked={allowChatNotification}
onChange={this.updateAllowChatNotification} onChange={this.updateAllowChatNotification}
name="allowChatNotification" name="allowChatNotification"
color={allowChatNotification ? 'secondary' : 'primary'} color={allowChatNotification ? "secondary" : "primary"}
/> />
} }
label={ label={
<span> <span>
Allow chat notification when side panel is closed Allow chat notification when side panel is closed
<br /> <br />
<span style={{ color: '#8a8a8a' }}> <span style={{ color: "#8a8a8a" }}>
{allowChatNotification ? 'Notifications Enabled' : 'Notifications Disabled'} {allowChatNotification
? "Notifications Enabled"
: "Notifications Disabled"}
</span> </span>
</span> </span>
} }
@@ -597,15 +656,17 @@ export default class Chat extends Component {
checked={allowAutoRejoin} checked={allowAutoRejoin}
onChange={this.updateAllowAutoRejoin} onChange={this.updateAllowAutoRejoin}
name="allowAutoRejoin" name="allowAutoRejoin"
color={allowAutoRejoin ? 'secondary' : 'primary'} color={allowAutoRejoin ? "secondary" : "primary"}
/> />
} }
label={ label={
<span> <span>
Allow Watch Party to auto rejoin (within 1 minute) Allow Watch Party to auto rejoin (within 1 minute)
<br /> <br />
<span style={{ color: '#8a8a8a' }}> <span style={{ color: "#8a8a8a" }}>
{allowAutoRejoin ? 'Auto Rejoin Enabled' : 'Auto Rejoin Disabled'} {allowAutoRejoin
? "Auto Rejoin Enabled"
: "Auto Rejoin Disabled"}
</span> </span>
</span> </span>
} }
@@ -619,7 +680,7 @@ export default class Chat extends Component {
checked={adminOnly} checked={adminOnly}
onChange={this.updateAdminOnly} onChange={this.updateAdminOnly}
name="adminOnly" name="adminOnly"
color={adminOnly ? 'secondary' : 'primary'} color={adminOnly ? "secondary" : "primary"}
disabled={adminModeUpdate} disabled={adminModeUpdate}
/> />
} }
@@ -627,38 +688,53 @@ export default class Chat extends Component {
<span> <span>
Admin Only Mode Admin Only Mode
<br /> <br />
<span style={{ color: '#8a8a8a' }}> <span style={{ color: "#8a8a8a" }}>
{adminOnly {adminOnly
? 'Only admin can update player and start calls right now' ? "Only admin can update player and start calls right now"
: 'All party members can update player and start calls right now'} : "All party members can update player and start calls right now"}
</span> </span>
</span> </span>
} }
labelPlacement="end" labelPlacement="end"
/> />
) : null} ) : null}
<Typography className="party-controls-users-title" variant="overline"> <Typography
className="party-controls-users-title"
variant="overline"
>
PARTY MEMBERS PARTY MEMBERS
</Typography> </Typography>
<div className="party-controls-users-container"> <div className="party-controls-users-container">
{users.map((user) => ( {users.map((user) => (
<Chip className="party-controls-users-chip" clickable size="small" label={user} /> <Chip
className="party-controls-users-chip"
clickable
size="small"
label={user}
/>
))} ))}
</div> </div>
{Object.keys(usersOnCall).length > 0 ? ( {Object.keys(usersOnCall).length > 0 ? (
<Typography className="party-controls-users-title" variant="overline"> <Typography
className="party-controls-users-title"
variant="overline"
>
MEMBERS IN CALL MEMBERS IN CALL
</Typography> </Typography>
) : null} ) : null}
{Object.keys(usersOnCall).length > 0 ? ( {Object.keys(usersOnCall).length > 0 ? (
<div className="party-controls-users-container"> <div className="party-controls-users-container">
{Object.keys(usersOnCall).map((id) => { {Object.keys(usersOnCall).map((id) => {
return usersOnCall[id].status === 'Connected' || return usersOnCall[id].status === "Connected" ||
usersOnCall[id].status === 'Connecting' ? ( usersOnCall[id].status === "Connecting" ? (
<Tooltip <Tooltip
interactive interactive
title={ title={
<Grid className="party-controls-users-volume" container spacing={2}> <Grid
className="party-controls-users-volume"
container
spacing={2}
>
<Grid item> <Grid item>
<VolumeDown /> <VolumeDown />
</Grid> </Grid>
@@ -669,7 +745,9 @@ export default class Chat extends Component {
step={1} step={1}
color="secondary" color="secondary"
value={volumes[id] || 10} value={volumes[id] || 10}
onChangeCommitted={(e, v) => this.setVideoVolume(v, id)} onChangeCommitted={(e, v) =>
this.setVideoVolume(v, id)
}
/> />
</Grid> </Grid>
<Grid item> <Grid item>
@@ -680,14 +758,15 @@ export default class Chat extends Component {
> >
<Chip <Chip
color={ color={
usersOnCall[id].info.externalId === LocalData().userUid usersOnCall[id].info.externalId ===
? 'secondary' LocalData().userUid
: 'default' ? "secondary"
: "default"
} }
className="party-controls-users-chip" className="party-controls-users-chip"
clickable clickable
size="small" size="small"
label={usersOnCall[id].info.name || ' '} label={usersOnCall[id].info.name || " "}
/> />
</Tooltip> </Tooltip>
) : null; ) : null;
@@ -698,13 +777,14 @@ export default class Chat extends Component {
</ExpansionPanel> </ExpansionPanel>
{player ? ( {player ? (
<Card elevation={0} className="media-info-card"> <Card elevation={0} className="media-info-card">
{player.showName && player.status !== PLAYER_STATUS.NOT_PLAYING ? ( {player.showName &&
player.status !== PLAYER_STATUS.NOT_PLAYING ? (
<CardContent> <CardContent>
<Typography className="media-info-at" variant="overline"> <Typography className="media-info-at" variant="overline">
{player.status === PLAYER_STATUS.PAUSED {player.status === PLAYER_STATUS.PAUSED
? `PAUSED AT ${this.getPrettyTime(player.time)}` ? `PAUSED AT ${this.getPrettyTime(player.time)}`
: player.status === PLAYER_STATUS.PLAYING : player.status === PLAYER_STATUS.PLAYING
? `STARTED PLAYING FROM ${this.getPrettyTime(player.time)}` ? `CURRENTLY PLAYING (${this.getPrettyTime(player.time)})`
: `SHOW IS AT ${this.getPrettyTime(player.time)}`} : `SHOW IS AT ${this.getPrettyTime(player.time)}`}
</Typography> </Typography>
<div className="media-info-container"> <div className="media-info-container">
@@ -723,12 +803,17 @@ export default class Chat extends Component {
) : ( ) : (
<CardContent> <CardContent>
<Typography className="media-info-at" variant="caption"> <Typography className="media-info-at" variant="caption">
Nothing playing right now Nothing playing right now, pause or play once after starting
a show to start sync.
</Typography> </Typography>
</CardContent> </CardContent>
)} )}
{player && player.showName && player.status ? ( {player && player.showName && player.status ? (
<Button className="media-info-link" href={player.url} startIcon={<LinkOutlined />}> <Button
className="media-info-link"
href={player.url}
startIcon={<LinkOutlined />}
>
Link to currently playing Link to currently playing
</Button> </Button>
) : null} ) : null}
@@ -759,7 +844,9 @@ export default class Chat extends Component {
<Paper <Paper
square square
variant="outlined" variant="outlined"
className={`replying-to-card ${replyTo !== null ? 'replying-to-card-up' : ''}`} className={`replying-to-card ${
replyTo !== null ? "replying-to-card-up" : ""
}`}
> >
<div className="replying-to-content"> <div className="replying-to-content">
<Typography variant="overline" display="block" gutterBottom> <Typography variant="overline" display="block" gutterBottom>
@@ -773,8 +860,15 @@ export default class Chat extends Component {
</Paper> </Paper>
<div className="text-phone-panel"> <div className="text-phone-panel">
{gif || newMessage ? null : ( {gif || newMessage ? null : (
<Tooltip title="Fullscreen with Watch Party" aria-label="Fullscreen"> <Tooltip
<IconButton className="icon-button" color="secondary" onClick={this.toggleFullscreen}> title="Fullscreen with Watch Party"
aria-label="Fullscreen"
>
<IconButton
className="icon-button"
color="secondary"
onClick={this.toggleFullscreen}
>
{isFullscreen ? <FullscreenExit /> : <Fullscreen />} {isFullscreen ? <FullscreenExit /> : <Fullscreen />}
</IconButton> </IconButton>
</Tooltip> </Tooltip>
@@ -785,7 +879,7 @@ export default class Chat extends Component {
<IconButton <IconButton
disabled={callActionPending} disabled={callActionPending}
onClick={this.handlePhoneCall} onClick={this.handlePhoneCall}
color={!onCall ? 'secondary' : 'primary'} color={!onCall ? "secondary" : "primary"}
className="icon-button" className="icon-button"
> >
{onCall ? ( {onCall ? (
@@ -827,12 +921,14 @@ export default class Chat extends Component {
multiline multiline
rowsMax="3" rowsMax="3"
size="small" size="small"
placeholder={this.state.gif ? 'Search something...' : 'Say something...'} placeholder={
this.state.gif ? "Search something..." : "Say something..."
}
helperText={ helperText={
this.state.newMessage && !this.state.gif this.state.newMessage && !this.state.gif
? 'Enter to send / Shift+Enter for new line' ? "Enter to send / Shift+Enter for new line"
: this.state.gif : this.state.gif
? 'Click on gif to send / Scroll to load more' ? "Click on gif to send / Scroll to load more"
: null : null
} }
variant="outlined" variant="outlined"
@@ -843,19 +939,19 @@ export default class Chat extends Component {
scrollThread(); scrollThread();
if (gif) { if (gif) {
window.postMessage({ window.postMessage({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_SEARCH_GIF', type: "WATCH_PARTY_SEARCH_GIF",
value: e.target.value, value: e.target.value,
}); });
} }
}} }}
InputProps={{ InputProps={{
id: 'chat-message-box-input', id: "chat-message-box-input",
endAdornment: ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton <IconButton
className={`${this.state.gif ? 'gif-active' : ''} ${ className={`${this.state.gif ? "gif-active" : ""} ${
this.state.newMessage ? 'message-active' : '' this.state.newMessage ? "message-active" : ""
} message-send`} } message-send`}
size="small" size="small"
onClick={() => this.sendMessageInvoker(newMessage)} onClick={() => this.sendMessageInvoker(newMessage)}
@@ -868,13 +964,15 @@ export default class Chat extends Component {
startAdornment: ( startAdornment: (
<InputAdornment position="start"> <InputAdornment position="start">
<IconButton <IconButton
className={`gif-button ${this.state.gif ? 'gif-close' : ''}`} className={`gif-button ${
this.state.gif ? "gif-close" : ""
}`}
onClick={() => { onClick={() => {
this.setState({ gif: !gif }); this.setState({ gif: !gif });
if (!gif) { if (!gif) {
window.postMessage({ window.postMessage({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_SEARCH_GIF', type: "WATCH_PARTY_SEARCH_GIF",
value: newMessage, value: newMessage,
}); });
scrollThread(); scrollThread();
@@ -892,9 +990,9 @@ export default class Chat extends Component {
<ReactGiphySearchbox <ReactGiphySearchbox
apiKey="ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq" apiKey="ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq"
onSelect={this.gifClick} onSelect={this.gifClick}
masonryConfig={[{ columns: 2, imageWidth: '50%', gutter: 5 }]} masonryConfig={[{ columns: 2, imageWidth: "50%", gutter: 5 }]}
searchFormClassName="giphy-search-form" searchFormClassName="giphy-search-form"
wrapperClassName={`giphy-wrapper ${gif ? '' : 'giphy-wrapper-down'}`} wrapperClassName={`giphy-wrapper ${gif ? "" : "giphy-wrapper-down"}`}
listWrapperClassName="giphy-list-wrapper" listWrapperClassName="giphy-list-wrapper"
listItemClassName="giphy-list-item" listItemClassName="giphy-list-item"
poweredByGiphy poweredByGiphy
+3
View File
@@ -206,6 +206,9 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
S Y S T E M S Y S T E M
M E S S A G E S M E S S A G E S
*/ */
.thread-item.thread-item.system-message {
margin: 0 auto !important;
}
.thread-item.system-message .thread-name, .thread-item.system-message .thread-name,
.thread-item.system-message .thread-reply, .thread-item.system-message .thread-reply,
.thread-item.system-message img, .thread-item.system-message img,
+226 -141
View File
@@ -9,19 +9,25 @@ ALL CONTENT ON WATCH PARTY'S WEBSITE OR IN WATCH PARTY'S CHROME EXTENSION APP, U
CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION. COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
************************************************************************/ ************************************************************************/
import { PLAYER_STATUS, getPlayerSource, PLAYER_SOURCE, LocalData } from './Api'; import {
PLAYER_STATUS,
getPlayerSource,
PLAYER_SOURCE,
LocalData,
} from "./Api";
const templateListener = (video) => console.log('MISSING VIDEO LISTENER'); const templateListener = (video) => console.log("MISSING VIDEO LISTENER");
export default class VideoListener { export default class VideoListener {
constructor(listener = templateListener, selectors) { constructor(listener = templateListener, selectors, nameSelectors) {
this.video = { this.video = {
status: PLAYER_STATUS.NOT_PLAYING, status: PLAYER_STATUS.NOT_PLAYING,
time: 0, time: 0,
showName: '', showName: "",
source: '', source: "",
element: null, element: null,
}; };
this.nameSelectors = nameSelectors;
this.selectors = selectors; this.selectors = selectors;
this.isUpdating = false; this.isUpdating = false;
this.listener = listener; this.listener = listener;
@@ -33,6 +39,7 @@ export default class VideoListener {
this.onplay = this.onplay.bind(this); this.onplay = this.onplay.bind(this);
this.shouldPushSync = this.shouldPushSync.bind(this); this.shouldPushSync = this.shouldPushSync.bind(this);
this.crunchyRollListener = this.crunchyRollListener.bind(this); this.crunchyRollListener = this.crunchyRollListener.bind(this);
this.getShowName = this.getShowName.bind(this);
} }
shouldPushSync() { shouldPushSync() {
return ( return (
@@ -42,7 +49,7 @@ export default class VideoListener {
this.video.element !== null && this.video.element !== null &&
this.video.element !== undefined && this.video.element !== undefined &&
this.video.status !== PLAYER_STATUS.NOT_PLAYING && this.video.status !== PLAYER_STATUS.NOT_PLAYING &&
this.video.showName !== '' && this.video.showName !== "" &&
this.video.showName !== null && this.video.showName !== null &&
(this.video.status !== this.server.status || (this.video.status !== this.server.status ||
Math.abs(this.video.element.currentTime - this.server.time) > 1.5) Math.abs(this.video.element.currentTime - this.server.time) > 1.5)
@@ -69,23 +76,31 @@ export default class VideoListener {
// REMOVE LISTENER BEFORE SYNCING // REMOVE LISTENER BEFORE SYNCING
switch (this.video.source) { switch (this.video.source) {
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
window.removeEventListener('watchParty', this.crunchyRollListener); window.removeEventListener("watchParty", this.crunchyRollListener);
break;
default: default:
this.video.element.removeEventListener('playing', this.onplay); this.video.element.removeEventListener("playing", this.onplay);
this.video.element.removeEventListener('pause', this.onpause); this.video.element.removeEventListener("pause", this.onpause);
} }
await this.timeout(250); await this.timeout(250);
// SEEK // SEEK
if (Math.abs(serverPlayer.time - this.video.element.currentTime) > 1.5) { if (
Math.abs(serverPlayer.time - this.video.element.currentTime) > 1.5
) {
switch (serverPlayer.source) { switch (serverPlayer.source) {
case PLAYER_SOURCE.NETFLIX: case PLAYER_SOURCE.NETFLIX:
window.postMessage({ type: 'SEEK', time: serverPlayer.time * 1000 }, '*'); window.postMessage(
{ type: "SEEK", time: serverPlayer.time * 1000 },
"*"
);
break; break;
case PLAYER_SOURCE.AMAZON: case PLAYER_SOURCE.AMAZON:
if (this.video.status === PLAYER_STATUS.PAUSED) if (this.video.status === PLAYER_STATUS.PAUSED)
await this.video.element await this.video.element
.play() .play()
.catch((err) => console.error('WatchParty erred when syncing time.')); .catch((err) =>
console.error("WatchParty erred when syncing time.")
);
await this.timeout(250); await this.timeout(250);
this.video.element.currentTime = serverPlayer.time; this.video.element.currentTime = serverPlayer.time;
await this.timeout(500); await this.timeout(500);
@@ -98,7 +113,10 @@ export default class VideoListener {
this.video.element.currentTime = serverPlayer.time; this.video.element.currentTime = serverPlayer.time;
break; break;
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.HBOMAX:
case PLAYER_SOURCE.HBONOW: case PLAYER_SOURCE.HBONOW:
@@ -107,8 +125,8 @@ export default class VideoListener {
case PLAYER_SOURCE.PEACOCK: case PLAYER_SOURCE.PEACOCK:
window.postMessage( window.postMessage(
JSON.stringify({ JSON.stringify({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_SEEK', type: "WATCH_PARTY_SEEK",
status: serverPlayer.status, status: serverPlayer.status,
time: serverPlayer.time, time: serverPlayer.time,
}) })
@@ -120,8 +138,8 @@ export default class VideoListener {
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
window.postMessage( window.postMessage(
JSON.stringify({ JSON.stringify({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_SEEK', type: "WATCH_PARTY_SEEK",
status: serverPlayer.status, status: serverPlayer.status,
time: serverPlayer.time, time: serverPlayer.time,
}) })
@@ -140,15 +158,18 @@ export default class VideoListener {
PLAYER_SOURCE.HBOMAX === this.video.source || PLAYER_SOURCE.HBOMAX === this.video.source ||
PLAYER_SOURCE.HBONOW === this.video.source PLAYER_SOURCE.HBONOW === this.video.source
) { ) {
window.postMessage({ type: 'PAUSE', time: serverPlayer.time }, '*'); window.postMessage(
{ type: "PAUSE", time: serverPlayer.time },
"*"
);
} else if ( } else if (
PLAYER_SOURCE.CRUNCHYROLL === this.video.source || PLAYER_SOURCE.CRUNCHYROLL === this.video.source ||
PLAYER_SOURCE.PEACOCK === this.video.source PLAYER_SOURCE.PEACOCK === this.video.source
) { ) {
window.postMessage( window.postMessage(
JSON.stringify({ JSON.stringify({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_STATUS', type: "WATCH_PARTY_STATUS",
status: serverPlayer.status, status: serverPlayer.status,
time: serverPlayer.time, time: serverPlayer.time,
}) })
@@ -164,15 +185,18 @@ export default class VideoListener {
PLAYER_SOURCE.HBOMAX === this.video.source || PLAYER_SOURCE.HBOMAX === this.video.source ||
PLAYER_SOURCE.HBONOW === this.video.source PLAYER_SOURCE.HBONOW === this.video.source
) { ) {
window.postMessage({ type: 'PLAY', time: serverPlayer.time }, '*'); window.postMessage(
{ type: "PLAY", time: serverPlayer.time },
"*"
);
} else if ( } else if (
PLAYER_SOURCE.CRUNCHYROLL === this.video.source || PLAYER_SOURCE.CRUNCHYROLL === this.video.source ||
PLAYER_SOURCE.PEACOCK === this.video.source PLAYER_SOURCE.PEACOCK === this.video.source
) { ) {
window.postMessage( window.postMessage(
JSON.stringify({ JSON.stringify({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_STATUS', type: "WATCH_PARTY_STATUS",
status: serverPlayer.status, status: serverPlayer.status,
time: serverPlayer.time, time: serverPlayer.time,
}) })
@@ -180,7 +204,9 @@ export default class VideoListener {
} else { } 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.")
);
} }
break; break;
default: default:
@@ -190,10 +216,10 @@ export default class VideoListener {
// RE-ADD LISTENERS FOR FUTURE SYNC // RE-ADD LISTENERS FOR FUTURE SYNC
switch (this.video.source) { switch (this.video.source) {
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
window.addEventListener('watchParty', this.crunchyRollListener); window.addEventListener("watchParty", this.crunchyRollListener);
default: default:
this.video.element.addEventListener('playing', this.onplay); this.video.element.addEventListener("playing", this.onplay);
this.video.element.addEventListener('pause', this.onpause); this.video.element.addEventListener("pause", this.onpause);
} }
} }
this.isUpdating = false; this.isUpdating = false;
@@ -206,77 +232,75 @@ export default class VideoListener {
}); });
} }
async getShowName() { async getShowName() {
const nS = this.nameSelectors[this.video.source];
switch (this.video.source) { switch (this.video.source) {
case PLAYER_SOURCE.NETFLIX: case PLAYER_SOURCE.NETFLIX:
const titleContainerParent = document.querySelector( var nshow = document.querySelector(nS.show).innerHTML || "";
'.PlayerControls--control-element.text-control.video-title' var nepisode = "";
); if (document.querySelectorAll(nS.episode)) {
if (titleContainerParent) { document
const titleContainer = titleContainerParent.firstChild; .querySelectorAll(nS.episode)
const nshow = titleContainer.querySelector('h4') .forEach((el) => (nepisode += el.innerHTML + " "));
? titleContainer.querySelector('h4').innerHTML
: titleContainer.innerHTML;
let nepisode = '';
titleContainer.querySelectorAll('span').forEach((e) => {
if (e.innerHTML) nepisode += e.innerHTML + ' ';
});
return nshow === '' && nepisode === '' ? null : nshow + '\n' + nepisode;
} }
break; return nshow === "" && nepisode === "" ? null : nshow + "\n" + nepisode;
case PLAYER_SOURCE.AMAZON: case PLAYER_SOURCE.AMAZON:
const ashow = const ashow = document.querySelector(nS.show).innerText || "";
document.querySelector( return ashow === "" ? null : ashow;
'#dv-web-player > div > div:nth-child(1) > div > div > div.webPlayerSDKUiContainer > div > div > div > div > div > div > div > div:nth-child(2) > div:nth-child(2)'
).innerText || '';
return ashow === '' ? null : ashow;
case PLAYER_SOURCE.HULU: case PLAYER_SOURCE.HULU:
const hshow = document.querySelector('.metadata-area__second-line').innerHTML; const hshow = document.querySelector(nS.show).innerText;
const hepisode = document.querySelector('.metadata-area__third-line').innerHTML; const hepisode = document
return hshow === '' && hepisode === '' ? null : hshow + '\n' + hepisode; .querySelector(nS.episode)
.innerText.replace(/\n/gi, " ");
return hshow === "" && hepisode === "" ? null : hshow + "\n" + hepisode;
case PLAYER_SOURCE.DISNEY: case PLAYER_SOURCE.DISNEY:
this.video.element.parentElement.click(); this.video.element.parentElement.click();
await this.timeout(200); await this.timeout(200);
const dshow = document.querySelector('.title-field') const dshow = document.querySelector(nS.show)
? document.querySelector('.title-field').innerHTML ? document.querySelector(nS.show).innerHTML
: ''; : "";
const depisode = document.querySelector('.subtitle-field') const depisode = document.querySelector(nS.episode)
? document.querySelector('.subtitle-field').innerHTML ? document.querySelector(nS.episode).innerHTML
: ''; : "";
return dshow === '' && depisode === '' ? null : dshow + '\n' + depisode; return dshow === "" && depisode === "" ? null : dshow + "\n" + depisode;
case PLAYER_SOURCE.YOUTUBE: case PLAYER_SOURCE.YOUTUBE:
const yshow = document.querySelector('h1.title').innerText; const yshow = document.querySelector(nS.show).innerText || "";
const yepisode = document.querySelector('yt-formatted-string.super-title').innerText; const yepisode = document.querySelector(nS.episode).innerText || "";
return yshow === '' && yepisode === '' ? null : yshow + '\n' + yepisode; return yshow === "" && yepisode === "" ? null : yshow + "\n" + yepisode;
case PLAYER_SOURCE.HBOMAX: case PLAYER_SOURCE.HBOMAX:
case PLAYER_SOURCE.HBONOW: case PLAYER_SOURCE.HBONOW:
const bottomHalf = this.video.element.parentNode.parentNode.parentNode.parentNode.parentNode const bottomHalf = this.video.element.parentNode.parentNode.parentNode
.children[1]; .parentNode.parentNode.children[1];
bottomHalf.children[0].id = 'hboUpperTitle'; bottomHalf.children[0].id = "hboUpperTitle";
bottomHalf.children[1].id = 'hboLowerTitle'; bottomHalf.children[1].id = "hboLowerTitle";
const hboshow = document.querySelector('#hboUpperTitle').innerText; const hboshow = document.querySelector("#hboUpperTitle").innerText;
const hboepisode = document.querySelector('#hboLowerTitle').innerText; const hboepisode = document.querySelector("#hboLowerTitle").innerText;
return hboshow === '' && hboepisode === '' ? null : hboshow + '\n' + hboepisode; return hboshow === "" && hboepisode === ""
case PLAYER_SOURCE.PEACOCK:
const peacockshow = document.querySelector(
'.item.playback-metadata__container-episode-metadata-info'
).innerText;
const peacockepisode = document.querySelector('.item.playback-metadata__container-title')
.innerText;
return peacockshow === '' && peacockepisode === ''
? null ? null
: peacockshow + '\n' + peacockepisode; : hboshow + "\n" + hboepisode;
case PLAYER_SOURCE.PEACOCK:
const peacockshow = document.querySelector(nS.show).innerText || "";
const peacockepisode =
document.querySelector(nS.episode).innerText || "";
return peacockshow === "" && peacockepisode === ""
? null
: peacockshow + "\n" + peacockepisode;
case PLAYER_SOURCE.GOOGLEPLAY: case PLAYER_SOURCE.GOOGLEPLAY:
const playerIframe = document.querySelector('body span div iframe'); const playerIframe = document.querySelector(
var googleplayshow = ''; this.selectors[PLAYER_SOURCE.GOOGLEPLAY]
);
var googleplayshow = "";
if (playerIframe) { if (playerIframe) {
const titleElement = playerIframe.contentWindow.document.querySelector('.playing-title'); googleplayshow =
googleplayshow = titleElement ? titleElement.innerText : ''; playerIframe.contentWindow.document.querySelector(nS.show)
.innerText || "";
} }
return googleplayshow === '' ? null : googleplayshow; return googleplayshow === "" ? null : googleplayshow;
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
const crunchyrollTitle = document.querySelector('#showmedia_about_media'); const crunchyrollTitle = document.querySelector(nS.show);
const crunchyrollshow = crunchyrollTitle ? crunchyrollTitle.innerText : ''; const crunchyrollshow = crunchyrollTitle
return crunchyrollshow === '' ? null : crunchyrollshow; ? crunchyrollTitle.innerText
: "";
return crunchyrollshow === "" ? null : crunchyrollshow;
default: default:
break; break;
} }
@@ -297,8 +321,8 @@ export default class VideoListener {
} }
async crunchyRollListener(ev) { async crunchyRollListener(ev) {
if ( if (
ev.detail.watchPartyDirection === 'TO_APP' && ev.detail.watchPartyDirection === "TO_APP" &&
ev.detail.type === 'WATCH_PARTY_PLAYER_UPDATE' ev.detail.type === "WATCH_PARTY_PLAYER_UPDATE"
) { ) {
this.updateStatus({ this.updateStatus({
status: ev.detail.status, status: ev.detail.status,
@@ -318,15 +342,15 @@ export default class VideoListener {
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
window.postMessage( window.postMessage(
JSON.stringify({ JSON.stringify({
watchPartyDirection: 'TO_SCRIPT', watchPartyDirection: "TO_SCRIPT",
type: 'WATCH_PARTY_ADD_LISTENERS', type: "WATCH_PARTY_ADD_LISTENERS",
}) })
); );
window.addEventListener('watchParty', this.crunchyRollListener); window.addEventListener("watchParty", this.crunchyRollListener);
break; break;
default: default:
videoElement.addEventListener('playing', this.onplay); videoElement.addEventListener("playing", this.onplay);
videoElement.addEventListener('pause', this.onpause); videoElement.addEventListener("pause", this.onpause);
} }
} }
async start() { async start() {
@@ -337,10 +361,12 @@ export default class VideoListener {
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);}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 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);
const videoElement = document.querySelector(this.selectors[PLAYER_SOURCE.NETFLIX]); const videoElement = document.querySelector(
this.selectors[PLAYER_SOURCE.NETFLIX]
);
if (videoElement && !this.video.element) { if (videoElement && !this.video.element) {
this.firstTimeSync(videoElement); this.firstTimeSync(videoElement);
} else { } else {
@@ -348,8 +374,13 @@ export default class VideoListener {
this.video.element this.video.element
? null ? null
: () => { : () => {
var nve = document.querySelector(this.selectors[PLAYER_SOURCE.NETFLIX]); var nve = document.querySelector(
if (nve !== null && (this.video.element !== nve || this.video.element === null)) { this.selectors[PLAYER_SOURCE.NETFLIX]
);
if (
nve !== null &&
(this.video.element !== nve || this.video.element === null)
) {
this.firstTimeSync(nve); this.firstTimeSync(nve);
} }
}, },
@@ -361,19 +392,26 @@ export default class VideoListener {
const huluSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${ const huluSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${
this.selectors[PLAYER_SOURCE.HULU] this.selectors[PLAYER_SOURCE.HULU]
}").__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);`; }").__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'); const huluSeekInjectScript = document.createElement("script");
huluSeekInjectScript.text = huluSeekInject; huluSeekInjectScript.text = huluSeekInject;
document.head.appendChild(huluSeekInjectScript); document.head.appendChild(huluSeekInjectScript);
const videoElement = document.querySelector(this.selectors[PLAYER_SOURCE.HULU]); const huluVideoElement = document.querySelector(
if (videoElement) { this.selectors[PLAYER_SOURCE.HULU]
this.firstTimeSync(videoElement); );
if (huluVideoElement) {
this.firstTimeSync(huluVideoElement);
} else { } else {
setInterval( setInterval(
this.video.element this.video.element
? null ? null
: () => { : () => {
var hve = document.querySelector(this.selectors[PLAYER_SOURCE.HULU]); var hve = document.querySelector(
if (hve !== null && (this.video.element !== hve || this.video.element === null)) { this.selectors[PLAYER_SOURCE.HULU]
);
if (
hve !== null &&
(this.video.element !== hve || this.video.element === null)
) {
this.firstTimeSync(hve); this.firstTimeSync(hve);
} }
}, },
@@ -382,16 +420,23 @@ export default class VideoListener {
} }
break; break;
case PLAYER_SOURCE.AMAZON: case PLAYER_SOURCE.AMAZON:
const videoElement = document.querySelector(this.selectors[PLAYER_SOURCE.AMAZON]); const amazonVideoElement = document.querySelector(
if (videoElement) { this.selectors[PLAYER_SOURCE.AMAZON]
this.firstTimeSync(videoElement); );
if (amazonVideoElement) {
this.firstTimeSync(amazonVideoElement);
} else { } else {
setInterval( setInterval(
this.video.element this.video.element
? null ? null
: () => { : () => {
var ave = document.querySelector(this.selectors[PLAYER_SOURCE.AMAZON]); var ave = document.querySelector(
if (ave !== null && (this.video.element !== ave || this.video.element === null)) { this.selectors[PLAYER_SOURCE.AMAZON]
);
if (
ave !== null &&
(this.video.element !== ave || this.video.element === null)
) {
this.firstTimeSync(ave); this.firstTimeSync(ave);
} }
}, },
@@ -400,7 +445,9 @@ export default class VideoListener {
} }
break; break;
case PLAYER_SOURCE.DISNEY: case PLAYER_SOURCE.DISNEY:
const disneyVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.DISNEY]); const disneyVideoElement = document.querySelector(
this.selectors[PLAYER_SOURCE.DISNEY]
);
if (disneyVideoElement) { if (disneyVideoElement) {
this.firstTimeSync(disneyVideoElement); this.firstTimeSync(disneyVideoElement);
} else { } else {
@@ -408,8 +455,13 @@ export default class VideoListener {
this.video.element this.video.element
? null ? null
: () => { : () => {
var dve = document.querySelector(this.selectors[PLAYER_SOURCE.DISNEY]); var dve = document.querySelector(
if (dve !== null && (this.video.element !== dve || this.video.element === null)) { this.selectors[PLAYER_SOURCE.DISNEY]
);
if (
dve !== null &&
(this.video.element !== dve || this.video.element === null)
) {
this.firstTimeSync(dve); this.firstTimeSync(dve);
} }
}, },
@@ -418,15 +470,22 @@ export default class VideoListener {
} }
break; break;
case PLAYER_SOURCE.YOUTUBE: case PLAYER_SOURCE.YOUTUBE:
const youtubeVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.YOUTUBE]); const youtubeVideoElement = document.querySelector(
this.selectors[PLAYER_SOURCE.YOUTUBE]
);
if (youtubeVideoElement) this.firstTimeSync(youtubeVideoElement); if (youtubeVideoElement) this.firstTimeSync(youtubeVideoElement);
else { else {
setInterval( setInterval(
this.video.element this.video.element
? null ? null
: () => { : () => {
var yve = document.querySelector(this.selectors[PLAYER_SOURCE.YOUTUBE]); var yve = document.querySelector(
if (yve !== null && (this.video.element !== yve || this.video.element === null)) { this.selectors[PLAYER_SOURCE.YOUTUBE]
);
if (
yve !== null &&
(this.video.element !== yve || this.video.element === null)
) {
this.firstTimeSync(yve); this.firstTimeSync(yve);
} }
}, },
@@ -438,22 +497,27 @@ export default class VideoListener {
const hboSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${ const hboSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${
this.selectors[PLAYER_SOURCE.HBOMAX] this.selectors[PLAYER_SOURCE.HBOMAX]
}")._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);`; }")._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'); const hboSeekInjectScript = document.createElement("script");
hboSeekInjectScript.text = hboSeekInject; hboSeekInjectScript.text = hboSeekInject;
document.head.appendChild(hboSeekInjectScript); document.head.appendChild(hboSeekInjectScript);
const hboVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.HBOMAX]); const hboVideoElement = document.querySelector(
this.selectors[PLAYER_SOURCE.HBOMAX]
);
if (hboVideoElement) { if (hboVideoElement) {
const bottomHalf = const bottomHalf =
hboVideoElement.parentNode.parentNode.parentNode.parentNode.parentNode.children[1]; hboVideoElement.parentNode.parentNode.parentNode.parentNode
bottomHalf.children[0].id = 'hboUpperTitle'; .parentNode.children[1];
bottomHalf.children[1].id = 'hboLowerTitle'; bottomHalf.children[0].id = "hboUpperTitle";
bottomHalf.children[1].id = "hboLowerTitle";
this.firstTimeSync(hboVideoElement); this.firstTimeSync(hboVideoElement);
} else { } else {
setInterval( setInterval(
this.video.element this.video.element
? null ? null
: () => { : () => {
var hve = document.querySelector(this.selectors[PLAYER_SOURCE.HBOMAX]); var hve = document.querySelector(
this.selectors[PLAYER_SOURCE.HBOMAX]
);
if ( if (
hve !== null && hve !== null &&
hve !== undefined && hve !== undefined &&
@@ -467,25 +531,30 @@ export default class VideoListener {
} }
break; break;
case PLAYER_SOURCE.HBONOW: case PLAYER_SOURCE.HBONOW:
const hboSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${ const hboNowSeekInject = `window.seekScriptLoaded=!0;var getVideoPlayer=function(){var e=document.querySelector("${
this.selectors[PLAYER_SOURCE.HBONOW] this.selectors[PLAYER_SOURCE.HBONOW]
}")._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);`; }")._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'); const hboNowSeekInjectScript = document.createElement("script");
hboSeekInjectScript.text = hboSeekInject; hboNowSeekInjectScript.text = hboNowSeekInject;
document.head.appendChild(hboSeekInjectScript); document.head.appendChild(hboNowSeekInjectScript);
const hboVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.HBONOW]); const hboNowVideoElement = document.querySelector(
if (hboVideoElement) { this.selectors[PLAYER_SOURCE.HBONOW]
);
if (hboNowVideoElement) {
const bottomHalf = const bottomHalf =
hboVideoElement.parentNode.parentNode.parentNode.parentNode.parentNode.children[1]; hboNowVideoElement.parentNode.parentNode.parentNode.parentNode
bottomHalf.children[0].id = 'hboUpperTitle'; .parentNode.children[1];
bottomHalf.children[1].id = 'hboLowerTitle'; bottomHalf.children[0].id = "hboUpperTitle";
this.firstTimeSync(hboVideoElement); bottomHalf.children[1].id = "hboLowerTitle";
this.firstTimeSync(hboNowVideoElement);
} else { } else {
setInterval( setInterval(
this.video.element this.video.element
? null ? null
: () => { : () => {
var hve = document.querySelector(this.selectors[PLAYER_SOURCE.HBONOW]); var hve = document.querySelector(
this.selectors[PLAYER_SOURCE.HBONOW]
);
if ( if (
hve !== null && hve !== null &&
hve !== undefined && hve !== undefined &&
@@ -502,10 +571,12 @@ export default class VideoListener {
const peacockInject = `var watchPartyInteraction=function(e){if(e.source===window){const data=JSON.parse(e.data);const playerReactElement=document.querySelector("${ const peacockInject = `var watchPartyInteraction=function(e){if(e.source===window){const data=JSON.parse(e.data);const playerReactElement=document.querySelector("${
this.selectors[PLAYER_SOURCE.PEACOCK] this.selectors[PLAYER_SOURCE.PEACOCK]
}");if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_SEEK'){if(playerReactElement&&playerReactElement.player){playerReactElement.player.seek(data.time)}}else if(data.type==='WATCH_PARTY_STATUS'){if(playerReactElement&&playerReactElement.player){if(data.status==='PAUSED')playerReactElement.player.pause();if(data.status==='PLAYING')playerReactElement.player.play()}}}}};window.addEventListener("message",watchPartyInteraction);`; }");if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_SEEK'){if(playerReactElement&&playerReactElement.player){playerReactElement.player.seek(data.time)}}else if(data.type==='WATCH_PARTY_STATUS'){if(playerReactElement&&playerReactElement.player){if(data.status==='PAUSED')playerReactElement.player.pause();if(data.status==='PLAYING')playerReactElement.player.play()}}}}};window.addEventListener("message",watchPartyInteraction);`;
const peacockInjectScript = document.createElement('script'); const peacockInjectScript = document.createElement("script");
peacockInjectScript.text = peacockInject; peacockInjectScript.text = peacockInject;
document.head.appendChild(peacockInjectScript); document.head.appendChild(peacockInjectScript);
const peacockVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.PEACOCK]); const peacockVideoElement = document.querySelector(
this.selectors[PLAYER_SOURCE.PEACOCK]
);
if (peacockVideoElement) { if (peacockVideoElement) {
this.firstTimeSync(peacockVideoElement); this.firstTimeSync(peacockVideoElement);
} else { } else {
@@ -513,7 +584,9 @@ export default class VideoListener {
this.video.element this.video.element
? null ? null
: () => { : () => {
var pve = document.querySelector(this.selectors[PLAYER_SOURCE.PEACOCK]); var pve = document.querySelector(
this.selectors[PLAYER_SOURCE.PEACOCK]
);
if ( if (
pve !== null && pve !== null &&
pve !== undefined && pve !== undefined &&
@@ -527,9 +600,13 @@ export default class VideoListener {
} }
break; break;
case PLAYER_SOURCE.GOOGLEPLAY: case PLAYER_SOURCE.GOOGLEPLAY:
const playerIframe = document.querySelector(this.selectors[PLAYER_SOURCE.GOOGLEPLAY]); const playerIframe = document.querySelector(
this.selectors[PLAYER_SOURCE.GOOGLEPLAY]
);
if (playerIframe) { if (playerIframe) {
const googlePlayVideoElement = playerIframe.contentWindow.document.querySelector('video'); const googlePlayVideoElement = playerIframe.contentWindow.document.querySelector(
"video"
);
if (googlePlayVideoElement) { if (googlePlayVideoElement) {
this.firstTimeSync(googlePlayVideoElement); this.firstTimeSync(googlePlayVideoElement);
} }
@@ -538,9 +615,13 @@ export default class VideoListener {
this.video.element this.video.element
? null ? null
: () => { : () => {
const pif = document.querySelector(this.selectors[PLAYER_SOURCE.GOOGLEPLAY]); const pif = document.querySelector(
this.selectors[PLAYER_SOURCE.GOOGLEPLAY]
);
if (pif) { if (pif) {
const gpve = pif.contentWindow.document.querySelector('video'); const gpve = pif.contentWindow.document.querySelector(
"video"
);
if (gpve) { if (gpve) {
this.firstTimeSync(gpve); this.firstTimeSync(gpve);
} }
@@ -551,10 +632,12 @@ export default class VideoListener {
} }
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
const crunchyRollInject = `var sendToWatchPartyApp = function(pS, pT) { var customWatchPartyEvent = new CustomEvent('watchParty', { detail: { watchPartyDirection: 'TO_APP', type: 'WATCH_PARTY_PLAYER_UPDATE', status: pS, time: pT } }); window.dispatchEvent(customWatchPartyEvent); }, watchPartyGetTimeAndSend = function(pS) { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.getCurrentTime(function(pT) { sendToWatchPartyApp(pS, pT); }); } }, watchPartySendPlaying = function() { watchPartyGetTimeAndSend('PLAYING'); }, watchPartySendPaused = function() { watchPartyGetTimeAndSend('PAUSED'); }, watchPartyInteraction = function(e) { if (e.source === window) { const data = JSON.parse(e.data); if (data.watchPartyDirection === 'TO_SCRIPT') { if (data.type === 'WATCH_PARTY_ADD_LISTENERS') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.on('play', watchPartySendPlaying, 'player.js'); window.VILOS_PLAYERJS.on('pause', watchPartySendPaused, 'player.js'); } } else if (data.type === 'WATCH_PARTY_SEEK') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.setCurrentTime(data.time); } } else if (data.type === 'WATCH_PARTY_STATUS') { if (window.VILOS_PLAYERJS) { if (data.status === 'PAUSED') window.VILOS_PLAYERJS.pause(); if (data.status === 'PLAYING') window.VILOS_PLAYERJS.play(); } } } } }; window.addEventListener("message", watchPartyInteraction);`; const crunchyRollInject = `var sendToWatchPartyApp = function(pS, pT) { var customWatchPartyEvent = new CustomEvent('watchParty', { detail: { watchPartyDirection: 'TO_APP', type: 'WATCH_PARTY_PLAYER_UPDATE', status: pS, time: pT } }); window.dispatchEvent(customWatchPartyEvent); }, watchPartyGetTimeAndSend = function(pS) { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.getCurrentTime(function(pT) { sendToWatchPartyApp(pS, pT); }); } }, watchPartySendPlaying = function() { watchPartyGetTimeAndSend('PLAYING'); }, watchPartySendPaused = function() { watchPartyGetTimeAndSend('PAUSED'); }, watchPartyInteraction = function(e) { if (e.source === window) { const data = JSON.parse(e.data); if (data.watchPartyDirection === 'TO_SCRIPT') { if (data.type === 'WATCH_PARTY_ADD_LISTENERS') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.on('play', watchPartySendPlaying, 'player.js'); window.VILOS_PLAYERJS.on('pause', watchPartySendPaused, 'player.js'); } } else if (data.type === 'WATCH_PARTY_SEEK') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.setCurrentTime(data.time); } } else if (data.type === 'WATCH_PARTY_STATUS') { if (window.VILOS_PLAYERJS) { if (data.status === 'PAUSED') window.VILOS_PLAYERJS.pause(); if (data.status === 'PLAYING') window.VILOS_PLAYERJS.play(); } } } } }; window.addEventListener("message", watchPartyInteraction);`;
const crunchyRollInjectScript = document.createElement('script'); const crunchyRollInjectScript = document.createElement("script");
crunchyRollInjectScript.text = crunchyRollInject; crunchyRollInjectScript.text = crunchyRollInject;
document.head.appendChild(crunchyRollInjectScript); document.head.appendChild(crunchyRollInjectScript);
const crunchyrollIframe = document.querySelector(this.selectors[PLAYER_SOURCE.CRUNCHYROLL]); const crunchyrollIframe = document.querySelector(
this.selectors[PLAYER_SOURCE.CRUNCHYROLL]
);
if (crunchyrollIframe) { if (crunchyrollIframe) {
this.firstTimeSync(crunchyrollIframe); this.firstTimeSync(crunchyrollIframe);
} else { } else {
@@ -562,7 +645,9 @@ export default class VideoListener {
this.video.element this.video.element
? null ? null
: () => { : () => {
const cif = document.querySelector(this.selectors[PLAYER_SOURCE.CRUNCHYROLL]); const cif = document.querySelector(
this.selectors[PLAYER_SOURCE.CRUNCHYROLL]
);
if (cif) { if (cif) {
this.firstTimeSync(cif); this.firstTimeSync(cif);
} }
@@ -572,7 +657,7 @@ export default class VideoListener {
} }
break; 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) {
this.firstTimeSync(localVideoElement); this.firstTimeSync(localVideoElement);
} }
@@ -584,12 +669,12 @@ export default class VideoListener {
end() { end() {
switch (this.video.source) { switch (this.video.source) {
case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.CRUNCHYROLL:
window.removeEventListener('watchParty', this.crunchyRollListener); window.removeEventListener("watchParty", this.crunchyRollListener);
break; break;
default: default:
if (this.video.element) { if (this.video.element) {
this.video.element.removeEventListener('playing', this.onplay); this.video.element.removeEventListener("playing", this.onplay);
this.video.element.removeEventListener('pause', this.onpause); this.video.element.removeEventListener("pause", this.onpause);
} }
} }
} }
+7 -3
View File
@@ -110,7 +110,8 @@ body.youtube.visible .ytp-tooltip.ytp-bottom.ytp-preview {
bottom: 100px !important; bottom: 100px !important;
top: unset !important; top: unset !important;
} }
body.youtube.visible td-two-column-browse-results-renderer.grid:not(.grid-disabled) { body.youtube.visible
td-two-column-browse-results-renderer.grid:not(.grid-disabled) {
max-width: calc(100% - 48px); max-width: calc(100% - 48px);
} }
body.youtube.visible ytd-miniplayer { body.youtube.visible ytd-miniplayer {
@@ -239,7 +240,7 @@ body.disney #party_wrapper * {
left: 0; left: 0;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-sizing: content-box; box-sizing: content-box !important;
} }
#party-loading.inactive .MuiSvgIcon-root { #party-loading.inactive .MuiSvgIcon-root {
font-size: 50px !important; font-size: 50px !important;
@@ -276,6 +277,9 @@ body.disney #party_wrapper * {
#party-routes-wrapper.visible { #party-routes-wrapper.visible {
right: 0; right: 0;
} }
#party-routes-wrapper input {
box-sizing: content-box !important;
}
.party-notification-container { .party-notification-container {
z-index: 99999 !important; z-index: 99999 !important;
bottom: 0.8rem !important; bottom: 0.8rem !important;
@@ -307,7 +311,7 @@ body.disney #party_wrapper * {
border: 1px solid white; border: 1px solid white;
background-color: black !important; background-color: black !important;
transition: all ease-in-out 0.3s !important; transition: all ease-in-out 0.3s !important;
background-image: url('chrome-extension://__MSG_@@extension_id__/android-icon-192x192.png'); background-image: url("chrome-extension://__MSG_@@extension_id__/android-icon-192x192.png");
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 75%; background-size: 75%;
+55 -26
View File
@@ -1,21 +1,27 @@
const admin = require('firebase-admin'); const admin = require("firebase-admin");
module.exports = async (req, res) => { module.exports = async (req, res) => {
const bodydata = JSON.parse(req.body); const bodydata = JSON.parse(req.body);
console.log('Requested Create - UID - ', bodydata.uid); console.log("Requested Create - UID - ", bodydata.uid);
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' }); if (!bodydata.userName)
if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' }); res.status(400).send({ message: "Missing user name" });
if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' }); if (!bodydata.partyName)
res.status(400).send({ message: "Missing party name" });
if (!bodydata.partyPin)
res.status(400).send({ message: "Missing party pin" });
const roomNameTaken = await admin const roomNameTaken = await admin
.firestore() .firestore()
.collection('rooms') .collection("rooms")
.doc(bodydata.partyName.replace('/', '\\')) .doc(bodydata.partyName.replace("/", "\\"))
.get() .get()
.then((docSnap) => docSnap.exists); .then((docSnap) => docSnap.exists);
if (roomNameTaken) return res.status(409).send({ message: 'That party name is already taken' }); if (roomNameTaken)
return res
.status(409)
.send({ message: "That party name is already taken" });
await admin await admin
.firestore() .firestore()
.collection('rooms') .collection("rooms")
.doc(bodydata.partyName) .doc(bodydata.partyName)
.set({ .set({
name: bodydata.partyName, name: bodydata.partyName,
@@ -26,17 +32,17 @@ module.exports = async (req, res) => {
adminOnly: bodydata.adminOnly, adminOnly: bodydata.adminOnly,
}) })
.catch((err) => { .catch((err) => {
res.status(500).send({ message: 'Unable to start party.' }); res.status(500).send({ message: "Unable to start party." });
console.error(err); console.error(err);
}); });
await admin await admin
.firestore() .firestore()
.collection('rooms') .collection("rooms")
.doc(bodydata.partyName) .doc(bodydata.partyName)
.collection('messages') .collection("messages")
.add({ .add({
uid: '<system>', uid: "<system>",
name: '', name: "",
text: `${bodydata.userName} started the party.`, text: `${bodydata.userName} started the party.`,
time: new Date(), time: new Date(),
}) })
@@ -48,9 +54,9 @@ module.exports = async (req, res) => {
}); });
await admin await admin
.firestore() .firestore()
.collection('rooms') .collection("rooms")
.doc(bodydata.partyName) .doc(bodydata.partyName)
.collection('users') .collection("users")
.doc(bodydata.uid) .doc(bodydata.uid)
.set({ .set({
admin: true, admin: true,
@@ -62,24 +68,47 @@ module.exports = async (req, res) => {
err err
); );
}); });
if ( if (bodydata.player && bodydata.player.source === "amazon.") {
bodydata.player &&
(bodydata.player.source === 'amazon.' || bodydata.player.source === 'hulu.')
) {
await admin await admin
.firestore() .firestore()
.collection('rooms') .collection("rooms")
.doc(bodydata.partyName) .doc(bodydata.partyName)
.collection('messages') .collection("messages")
.add({ .add({
uid: '<system>', uid: "<system>",
name: '', name: "Update to V1.6.1",
endpoint: "https://get.chromewatchparty.com",
type: "interactive/link",
text: `If Watch Party doesn't work make sure you're on V1.6.1. Try removing and re-adding if an update option is not visible`,
time: new Date(),
})
.catch((err) => {
console.error(
`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`,
err
);
});
}
if (bodydata.player && bodydata.player.source === "hulu.") {
await admin
.firestore()
.collection("rooms")
.doc(bodydata.partyName)
.collection("messages")
.add({
uid: "<system>",
name: "",
text: `Watch Party may not work temporarily. An update is coming to fix this.`, text: `Watch Party may not work temporarily. An update is coming to fix this.`,
time: new Date(), time: new Date(),
}) })
.catch((err) => { .catch((err) => {
console.error(`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`, err); console.error(
`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`,
err
);
}); });
} }
res.status(201).send({ roomId: bodydata.partyName, message: 'Started a party!' }); res
.status(201)
.send({ roomId: bodydata.partyName, message: "Started a party!" });
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-api", "name": "watch-party-api",
"version": "1.6.0", "version": "1.6.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "watch-party-api", "name": "watch-party-api",
"version": "1.6.1", "version": "1.6.2",
"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.6.1", "version": "1.6.2",
"description": "Watch Party", "description": "Watch Party",
"scripts": { "scripts": {
"start": "firebase emulators:start", "start": "firebase emulators:start",
+11 -8
View File
@@ -212,6 +212,17 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
Yes, Watch Party is not a hack. The sole purpose of Watch Party is to help synchronize the playing/pausing on streamed content. Yes, Watch Party is not a hack. The sole purpose of Watch Party is to help synchronize the playing/pausing on streamed content.
</p> </p>
</div> </div>
<div class="tip">
<h6 data-font="sans">
CAN I DISABLE WATCH PARTY TEMPORARILY
</h6>
<p data-font="sans-bold">
Watch Party is built to not be in your way but, it can be manually disabled by going to the Chrome Extensions page (chrome://extensions) and toggling the little blue switch next to Watch Party.
<br />
You can alternatively go to a supported website, then right click on the Watch Party icons in toolbar (next to your user icon in the top right of Chrome), select "This can read and change site data", and change that to "When you click the extension" option. This will require you to click on the icon when you want to activate Watch Party.
</p>
</div>
<div class="tip"> <div class="tip">
<h6 data-font="sans"> <h6 data-font="sans">
HOW CAN I HELP KEEP WATCH PARTY ALIVE HOW CAN I HELP KEEP WATCH PARTY ALIVE
@@ -260,14 +271,6 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
Click on the title card in the sidebar, and click on the End Party button. Ending a party immediately deletes all data. Click on the title card in the sidebar, and click on the End Party button. Ending a party immediately deletes all data.
</p> </p>
</div> </div>
<div class="tip">
<h6 data-font="sans">
CAN I DISABLE WATCH PARTY TEMPORARILY
</h6>
<p data-font="sans-bold">
Watch Party is built to not be in your way but, it can be manually disabled by going to the Chrome Extensions page (chrome://extensions).
</p>
</div>
<a data-font="sans-bold" href="mailto:admin@chromewatchparty.com?subject=New FAQ Question" class="link-button"> <a data-font="sans-bold" href="mailto:admin@chromewatchparty.com?subject=New FAQ Question" class="link-button">
Ask A New Question Ask A New Question
</a> </a>