Salta al contenuto principale Scopri come sfruttare al meglio l'intelligenza artificiale agents, Microsoft 365 Copilot e altro ancora. Partecipa alla conferenza della community Microsoft 365 dal 21 al 23 aprile.
Scopri di più
{ const placeholder = document.createElement('div'); placeholder.className = 'youtube-consent-placeholder'; placeholder.dataset.src = iframe.src; placeholder.style.width = iframe.style.width || '100%'; placeholder.style.height = iframe.style.height || '315px'; placeholder.style.background = "#000"; placeholder.style.display = "flex"; placeholder.style.alignItems = "center"; placeholder.style.justifyContent = "center"; placeholder.style.color = "#fff"; placeholder.innerText = message; iframe.replaceWith(placeholder); deferredYouTubeEmbeds.push(placeholder); }); } function loadYouTubeEmbeds() { deferredYouTubeEmbeds.forEach(placeholder => { const iframe = document.createElement('iframe'); iframe.src = placeholder.dataset.src; iframe.setAttribute('allowfullscreen', ''); iframe.setAttribute('frameborder', '0'); iframe.setAttribute('loading', 'lazy'); iframe.style.width = placeholder.style.width; iframe.style.height = placeholder.style.height; placeholder.replaceWith(iframe); }); deferredYouTubeEmbeds = []; } function onConsentChanged(categoryPreferences) { console.log("🍪 Consent changed:", categoryPreferences); if (categoryPreferences?.Marketing || categoryPreferences?.SocialMedia) { loadYouTubeEmbeds(); } } function initConsentAndYouTube() { WcpConsent.init( locale, bannerId, function (err, siteConsent) { if (err) { console.error("❌ MSCC init error:", err); return; } window._wcpConsent = siteConsent; // 👈 CRITICAL for the link to work // ✅ This ensures the Manage Cookies link will work window._wcpConsent = siteConsent; const consent = siteConsent.getConsent(); console.log("✅ MSCC initialized. Current consent:", consent); if (consent?.Marketing || consent?.SocialMedia) { loadYouTubeEmbeds(); } else { deferYouTubeEmbeds(); } }, onConsentChanged, WcpConsent.themes.light, "test-nonce", { forceShowBanner: true, siteBehavior: { enableAutoConsent: false, allowImplicitConsent: false }, fallbackBehavior: { waitForConsent: true, defaultConsent: { Required: false, Analytics: false, SocialMedia: false, Marketing: false, Advertising: false } } } ); } document.addEventListener("DOMContentLoaded", () => { const waitForMSCC = setInterval(() => { if (window.WcpConsent?.init) { clearInterval(waitForMSCC); initConsentAndYouTube(); } }, 100); }); })(); const placeholder = document.createElement('div'); placeholder.className = 'youtube-consent-placeholder'; placeholder.dataset.src = iframe.src; placeholder.style.width = iframe.style.width || '100%'; placeholder.style.height = iframe.style.height || '315px'; placeholder.style.background = "#000"; placeholder.style.display = "flex"; placeholder.style.alignItems = "center"; placeholder.style.justifyContent = "center"; placeholder.style.color = "#fff"; placeholder.innerText = message; iframe.replaceWith(placeholder); deferredYouTubeEmbeds.push(placeholder); }); } function loadYouTubeEmbeds() { deferredYouTubeEmbeds.forEach(placeholder => { const iframe = document.createElement('iframe'); iframe.src = placeholder.dataset.src; iframe.setAttribute('allowfullscreen', ''); iframe.setAttribute('frameborder', '0'); iframe.setAttribute('loading', 'lazy'); iframe.style.width = placeholder.style.width; iframe.style.height = placeholder.style.height; placeholder.replaceWith(iframe); }); deferredYouTubeEmbeds = []; } function onConsentChanged(categoryPreferences) { console.log("🍪 Consent changed:", categoryPreferences); if (categoryPreferences?.Marketing || categoryPreferences?.SocialMedia) { loadYouTubeEmbeds(); } } function initConsentAndYouTube() { WcpConsent.init( locale, bannerId, function (err, siteConsent) { if (err) { console.error("❌ MSCC init error:", err); return; } window._wcpConsent = siteConsent; // 👈 CRITICAL for the link to work // ✅ This ensures the Manage Cookies link will work window._wcpConsent = siteConsent; const consent = siteConsent.getConsent(); console.log("✅ MSCC initialized. Current consent:", consent); if (consent?.Marketing || consent?.SocialMedia) { loadYouTubeEmbeds(); } else { deferYouTubeEmbeds(); } }, onConsentChanged, WcpConsent.themes.light, "test-nonce", { forceShowBanner: true, siteBehavior: { enableAutoConsent: false, allowImplicitConsent: false }, fallbackBehavior: { waitForConsent: true, defaultConsent: { Required: false, Analytics: false, SocialMedia: false, Marketing: false, Advertising: false } } } ); } document.addEventListener("DOMContentLoaded", () => { const waitForMSCC = setInterval(() => { if (window.WcpConsent?.init) { clearInterval(waitForMSCC); initConsentAndYouTube(); } }, 100); }); })();