From 5b7f247af3845ed53c0bbeef45e3642941a39779 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Tue, 18 May 2021 20:35:19 +0200 Subject: [PATCH] Using new placeholder. WIP. --- client/videowatch-client-plugin.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/videowatch-client-plugin.ts b/client/videowatch-client-plugin.ts index 55702596..b77bad99 100644 --- a/client/videowatch-client-plugin.ts +++ b/client/videowatch-client-plugin.ts @@ -178,12 +178,16 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { logger.error('No video provided') return } - const videoWrapper = document.querySelector('#video-wrapper') - if (!videoWrapper) { - logger.error('The required div is not present in the DOM.') + // Peertube >= 3.2.0 provide #plugin-placeholder-player-next + const placeholder = + document.getElementById('plugin-placeholder-player-next') ?? + document.getElementById('video-wrapper') + if (!placeholder) { + logger.error('The required placeholder div is not present in the DOM.') return } - let container = videoWrapper.querySelector('#peertube-plugin-livechat-container') + + let container = placeholder.querySelector('#peertube-plugin-livechat-container') if (container) { logger.log('The chat seems already initialized...') return @@ -191,7 +195,7 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { container = document.createElement('div') container.setAttribute('id', 'peertube-plugin-livechat-container') container.setAttribute('peertube-plugin-livechat-state', 'initializing') - videoWrapper.append(container) + placeholder.append(container) peertubeHelpers.getSettings().then((s: any) => { settings = s