Skip to content

Commit

Permalink
fix: Fix setting service when consent is not required
Browse files Browse the repository at this point in the history
Also hide `<evlplayer />` with no default video

Fixes #73
  • Loading branch information
octfx committed Nov 11, 2023
1 parent cd53e51 commit 01cfcd7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
{ "name": "iframe.js", "file": "modules/iframe.js" }
],
"styles": [
"ext.embedVideo.consent.less"
"ext.embedVideo.consent.less",
"ext.embedVideo.evl.less"
],
"position": "top",
"targets": [
Expand Down
5 changes: 5 additions & 0 deletions resources/ext.embedVideo.evl.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.evlplayer {
&[data-service="videolink"] {
display: none;
}
}
9 changes: 6 additions & 3 deletions resources/ext.embedVideo.videolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ const {makeIframe, fetchThumb} = require('./iframe.js');
evl.addEventListener('click', e => {
e.preventDefault();

const player = evl?.dataset?.player ?? 'default';
const iframeConfig = JSON.parse(evl.dataset.iframeconfig);
const player = evl.dataset?.player ?? 'default';
const iframeConfig = JSON.parse(evl.dataset?.iframeconfig ?? '{}');

const iframe = document.querySelector(`.embedvideo.evlplayer-${player} iframe`);
const playerContainer = document.querySelector(`.embedvideo.evlplayer-${player}`);
const iframe = playerContainer.querySelector('iframe');
// Iframe exists, no consent required or already given
if (iframe !== null) {
playerContainer.dataset.service = evl.dataset?.service ?? 'youtube';

for (const [key, value] of Object.entries(iframeConfig)) {
iframe.setAttribute(key, value);
}
Expand Down

0 comments on commit 01cfcd7

Please sign in to comment.