diff --git a/app/public/manifest.json b/app/public/manifest.json index c41c830..12bd08f 100644 --- a/app/public/manifest.json +++ b/app/public/manifest.json @@ -20,7 +20,8 @@ "https://*.peacocktv.com/*", "https://play.google.com/movies/*", "https://*.crunchyroll.com/*", - "https://tv.apple.com/*" + "https://tv.apple.com/*", + "https://*.viki.com/*" ], "content_security_policy": "script-src 'self' https://unpkg.com/ https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'", "content_scripts": [ @@ -36,7 +37,8 @@ "https://*.peacocktv.com/*", "https://play.google.com/*", "https://*.crunchyroll.com/*", - "https://tv.apple.com/*" + "https://tv.apple.com/*", + "https://*.viki.com/*" ], "run_at": "document_idle", "js": ["/static/js/content.js"], diff --git a/app/src/Api.js b/app/src/Api.js index e2b5787..c535276 100644 --- a/app/src/Api.js +++ b/app/src/Api.js @@ -31,6 +31,7 @@ export const PLAYER_SOURCE = { GOOGLEPLAY: 'play.google.', CRUNCHYROLL: 'crunchyroll.', APPLE: 'tv.apple.', + VIKI: 'viki.', LOCAL: 'localhost', }; @@ -47,6 +48,7 @@ export const getPlayerSource = () => { if (HREF.includes(PLAYER_SOURCE.GOOGLEPLAY)) return PLAYER_SOURCE.GOOGLEPLAY; if (HREF.includes(PLAYER_SOURCE.CRUNCHYROLL)) return PLAYER_SOURCE.CRUNCHYROLL; if (HREF.includes(PLAYER_SOURCE.APPLE)) return PLAYER_SOURCE.APPLE; + if (HREF.includes(PLAYER_SOURCE.VIKI)) return PLAYER_SOURCE.VIKI; if (HREF.includes(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL; }; diff --git a/app/src/App.js b/app/src/App.js index 69a2cc9..fd7ebd0 100644 --- a/app/src/App.js +++ b/app/src/App.js @@ -110,24 +110,34 @@ const App = () => { if (visible) { document.body.classList.add('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.add('visible'); - if ( - !hasAttached && - (getPlayerSource() === PLAYER_SOURCE.HBOMAX || getPlayerSource() === PLAYER_SOURCE.HBONOW) - ) { - document.addEventListener( - 'mousedown', - function (ev) { - if (document.body.querySelector('body.visible')) { - ev.preventDefault(); - ev.stopPropagation(); - ev.stopImmediatePropagation(); - } - }, - { capture: true } - ); - hasAttached = true; + if (getPlayerSource() === PLAYER_SOURCE.HBOMAX || getPlayerSource() === PLAYER_SOURCE.HBONOW) { + setTutorialComplete(true); + if (!hasAttached) { + document.addEventListener( + 'mousedown', + function (ev) { + if (document.body.querySelector('body.visible')) { + ev.preventDefault(); + ev.stopPropagation(); + ev.stopImmediatePropagation(); + } + }, + { capture: true } + ); + hasAttached = true; + } + } + if (getPlayerSource() === PLAYER_SOURCE.APPLE) { + const appleTvPlayer = document.querySelector('apple-tv-plus-player'); + const takeoverContainer = appleTvPlayer.shadowRoot.querySelector('.takeover.container.show'); + if (takeoverContainer) takeoverContainer.style.maxWidth = 'var(--body-width)'; } } else { + if (getPlayerSource() === PLAYER_SOURCE.APPLE) { + const appleTvPlayer = document.querySelector('apple-tv-plus-player'); + const takeoverContainer = appleTvPlayer.shadowRoot.querySelector('.takeover.container.show'); + if (takeoverContainer) takeoverContainer.style.maxWidth = 'none'; + } document.body.classList.remove('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.remove('visible'); } diff --git a/app/src/Thread.js b/app/src/Thread.js index 2ffa4be..390aac0 100644 --- a/app/src/Thread.js +++ b/app/src/Thread.js @@ -195,7 +195,7 @@ export default class Thread extends Component { return ( {({ height, width }) => { - if (autoSizeWidth && autoSizeWidth !== width) { + if (autoSizeWidth !== width) { cache.clearAll(); this.listRef.current.recomputeRowHeights(); this.setState({ autoSizeWidth: width }); diff --git a/app/src/VideoListener.js b/app/src/VideoListener.js index 16fc2a0..8b4d1b1 100644 --- a/app/src/VideoListener.js +++ b/app/src/VideoListener.js @@ -134,6 +134,9 @@ export default class VideoListener { case PLAYER_SOURCE.APPLE: this.video.element.currentTime = serverPlayer.time; break; + case PLAYER_SOURCE.VIKI: + this.video.element.currentTime = serverPlayer.time; + break; default: break; } @@ -276,11 +279,19 @@ export default class VideoListener { const appleTvPlayer = document.querySelector('apple-tv-plus-player'); const appleTvInternal = appleTvPlayer.shadowRoot.querySelector('amp-video-player-internal'); const appleTvVideoContainer = appleTvInternal.shadowRoot.querySelector('amp-video-player'); - const appleTvShow = appleTvVideoContainer.querySelector(nS.show).innerText || ''; - const appleTvEpisode = appleTvVideoContainer.querySelector(nS.episode).innerText || ''; + + const appleTvShowContainer = appleTvVideoContainer.querySelector(nS.show); + const appleTvEpisodeContainer = appleTvVideoContainer.querySelector(nS.episode); + + const appleTvShow = appleTvShowContainer ? appleTvShowContainer.innerText : ''; + const appleTvEpisode = appleTvEpisodeContainer ? appleTvEpisodeContainer.innerText : ''; return appleTvShow === '' && appleTvEpisode === '' ? null : appleTvShow + '\n' + appleTvEpisode; + case PLAYER_SOURCE.VIKI: + const docTitleSplit = document.title.split('|'); + if (docTitleSplit.length > 1) return docTitleSplit[0].trim(); + else return null; default: break; } @@ -599,9 +610,14 @@ export default class VideoListener { const ati = atp.shadowRoot.querySelector('amp-video-player-internal'); const atv = ati.shadowRoot.querySelector('amp-video-player'); const atve = atv.shadowRoot.querySelector(this.selectors[PLAYER_SOURCE.APPLE]); - if (atve) { - const tc = atp.shadowRoot.querySelector('.takeover.container.show'); - if (tc) tc.style.maxWidth = 'var(--body-width)'; + const tc = atp.shadowRoot.querySelector('.takeover.container.show'); + const visible = document.querySelector('body.visible'); + if (tc && visible) tc.style.maxWidth = 'var(--body-width)'; + else if (tc && !visible) tc.style.maxWidth = 'none'; + if ( + !!atve === true && + (!!this.video.element === false || atve !== this.video.element) + ) { this.firstTimeSync(atve); } }, @@ -609,6 +625,24 @@ export default class VideoListener { ); } break; + case PLAYER_SOURCE.VIKI: + const vikiVideoElement = document.querySelector(this.selectors[PLAYER_SOURCE.VIKI]); + if (vikiVideoElement) { + this.firstTimeSync(vikiVideoElement); + } else { + setInterval( + this.video.element + ? null + : () => { + var vve = document.querySelector(this.selectors[PLAYER_SOURCE.VIKI]); + if (vve !== null && (this.video.element !== vve || this.video.element === null)) { + this.firstTimeSync(vve); + } + }, + 1000 + ); + } + break; case PLAYER_SOURCE.LOCAL: const localVideoElement = document.getElementsByTagName('video')[0]; if (localVideoElement) { diff --git a/app/src/index.css b/app/src/index.css index 99f4ce4..d2b429c 100644 --- a/app/src/index.css +++ b/app/src/index.css @@ -77,7 +77,7 @@ body.disney.visible #hudson-wrapper, /* DISNEY */ body.youtube.visible #content.ytd-app, /* YOUTUBE */ body.youtube.visible #masthead-container, /* YOUTUBE HEADER */ body.googleplay.visible div.llhEMd.bYEzqc.LAhoGb.iWO5td, /* GOOGLE PLAY MOVIES */ -body.apple.visible .container.takeover.show /* APPLE TV */ { +body.viki.visible div.video-player /* VIKI */ { max-width: var(--body-width) !important; } /* HULU MINIMIZED VIDEO */ diff --git a/app/src/index.js b/app/src/index.js index 3838291..1006c89 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -97,6 +97,9 @@ switch (getPlayerSource()) { case PLAYER_SOURCE.APPLE: document.body.classList.add('apple'); break; + case PLAYER_SOURCE.VIKI: + document.body.classList.add('viki'); + break; case PLAYER_SOURCE.LOCAL: document.body.classList.add('local'); break;