|
138 | 138 | const platform = player.dataset.videoPlatform; |
139 | 139 | if (hasConsent(platform)) { |
140 | 140 | const videoId = player.dataset.videoId; |
141 | | - |
142 | 141 | // Check if src is already set - if so, the player is already properly configured |
143 | 142 | if (player.hasAttribute('src')) { |
144 | 143 | // Make sure the player is visible and the placeholder is hidden |
|
147 | 146 | if (placeholder?.classList.contains('consent-placeholder')) { |
148 | 147 | placeholder.style.display = 'none'; |
149 | 148 | } |
| 149 | + // --- ReferrerPolicy Patch für YouTube/Vimeo --- |
| 150 | + setReferrerPolicyOnProvider(player); |
150 | 151 | return; |
151 | 152 | } |
152 | | - |
153 | 153 | // Only recreate the player if no src is set |
154 | 154 | const placeholder = player.previousElementSibling; |
155 | 155 | rebuildMediaPlayer(player, platform, videoId, placeholder); |
156 | 156 | } |
157 | 157 | } |
158 | 158 |
|
| 159 | + // Setzt referrerPolicy auf YouTube/Vimeo-Provider, falls vorhanden |
| 160 | + function setReferrerPolicyOnProvider(player) { |
| 161 | + // Warte, bis der Provider geladen ist |
| 162 | + player.addEventListener('provider-change', function handler(e) { |
| 163 | + const provider = e.detail; |
| 164 | + if (!provider) return; |
| 165 | + // YouTube oder Vimeo Provider? |
| 166 | + if (provider.type === 'youtube' || provider.type === 'vimeo') { |
| 167 | + try { |
| 168 | + provider.referrerPolicy = 'strict-origin-when-cross-origin'; |
| 169 | + if (provider.iframe) { |
| 170 | + provider.iframe.referrerPolicy = 'strict-origin-when-cross-origin'; |
| 171 | + } |
| 172 | + } catch (err) { |
| 173 | + // Ignorieren, falls nicht möglich |
| 174 | + } |
| 175 | + } |
| 176 | + // Nur einmal ausführen |
| 177 | + player.removeEventListener('provider-change', handler); |
| 178 | + }); |
| 179 | + } |
| 180 | + |
159 | 181 | function applyTranslations() { |
160 | 182 | ['media-video-layout', 'media-audio-layout'].forEach(selector => { |
161 | 183 | document.querySelectorAll(selector).forEach(layout => { |
|
0 commit comments