diff --git a/extension.json b/extension.json index cd3207f..9c8e398 100644 --- a/extension.json +++ b/extension.json @@ -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": [ diff --git a/resources/ext.embedVideo.evl.less b/resources/ext.embedVideo.evl.less new file mode 100644 index 0000000..673bf43 --- /dev/null +++ b/resources/ext.embedVideo.evl.less @@ -0,0 +1,5 @@ +.evlplayer { + &[data-service="videolink"] { + display: none; + } +} \ No newline at end of file diff --git a/resources/ext.embedVideo.videolink.js b/resources/ext.embedVideo.videolink.js index b9e3aba..c38ec93 100644 --- a/resources/ext.embedVideo.videolink.js +++ b/resources/ext.embedVideo.videolink.js @@ -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); }