Last active
April 28, 2026 09:00
-
-
Save webtoffee-git/51fbc6452ee327d2d64718ab85566429 to your computer and use it in GitHub Desktop.
Listen for consent and replace the iframe src conditionally - by WebToffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener("wcc_consent_update", function (eventData) { | |
| const categories = eventData.detail.categories; | |
| const accepted = categories && categories.accepted; | |
| document.querySelectorAll('iframe[data-src*="youtube.com"]').forEach(function (iframe) { | |
| if (accepted && accepted.includes('marketing')) { | |
| iframe.src = iframe.getAttribute('data-src'); | |
| } else { | |
| iframe.removeAttribute('src'); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment