@@ -8,11 +8,30 @@ define([
88 'use strict' ;
99
1010 return function ( originalWidget ) {
11+ function isSupportedVideoPlatform ( url ) {
12+ if ( ! url ) {
13+ return false ;
14+ }
15+
16+ // Regex patterns for supported video platforms
17+ const youtubePattern = / ^ h t t p s ? : \/ \/ ( w w w \. ) ? ( y o u t u b e \. c o m | y o u t u \. b e ) \/ / i;
18+ const youtubeNocookiePattern = / ^ h t t p s ? : \/ \/ ( w w w \. ) ? y o u t u b e - n o c o o k i e \. c o m \/ / i;
19+ const vimeoPattern = / ^ h t t p s ? : \/ \/ ( w w w \. ) ? ( v i m e o \. c o m | p l a y e r \. v i m e o \. c o m ) \/ / i;
20+
21+ return youtubePattern . test ( url ) ||
22+ youtubeNocookiePattern . test ( url ) ||
23+ vimeoPattern . test ( url ) ;
24+ }
25+
1126 return function ( config , element ) {
1227 const videoElement = element [ 0 ] . querySelector ( '[data-background-type=video]' ) ;
1328 const blockVideoConsentConfig = window . cookiebotConfig && window . cookiebotConfig . blockVideosUntilConsent ;
29+ const videoSrc = videoElement . getAttribute ( 'data-video-src' ) ;
30+ const cookieblockSrc = videoElement . getAttribute ( 'data-cookieblock-src' ) ;
31+ const src = videoSrc || cookieblockSrc ;
1432 let previousStatus = '' ;
15- if ( ! videoElement || ! blockVideoConsentConfig ) {
33+
34+ if ( ! videoElement || ! blockVideoConsentConfig || ! isSupportedVideoPlatform ( src ) ) {
1635 originalWidget ( config , element ) ;
1736 return ;
1837 }
@@ -23,7 +42,7 @@ define([
2342 addEventListener ( 'CookiebotOnLoad' , sliderVideoBlocker ) ;
2443
2544 function sliderVideoBlocker ( ) {
26- if ( previousStatus === 'blocked' && ! Cookiebot ?. consent ?. marketing ) {
45+ if ( previousStatus === 'blocked' && ( ! Cookiebot ?. consent ?. marketing ) ) {
2746 return ;
2847 }
2948
0 commit comments