if (!areCookiesEnabled()) { const warningEl = document.getElementById('cookie-warning'); if (warningEl) { warningEl.classList.remove('hidden'); // Optional: Log for analytics console.warn('[Cookie Check] Cookies are blocked in this browser'); // You could send this to your analytics service if (typeof gtag !== 'undefined') { gtag('event', 'cookies_blocked', { 'event_category': 'user_preferences', 'event_label': navigator.userAgent }); } } } }
// Main check and display logic function checkAndNotify() { // Check if user has dismissed the warning before const dismissed = localStorage.getItem('cookieWarningDismissed'); if (dismissed && Date.now() - parseInt(dismissed) < 24 * 60 * 60 * 1000) { return; // Don't show again for 24 hours if dismissed } your browser is currently set to block cookies
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } if (warningEl) { warningEl.classList.remove('hidden')
modal.innerHTML = ` <div style="background: white; border-radius: 12px; max-width: 450px; width: 90%; padding: 25px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);"> <h3 style="margin-top: 0;">Enable Cookies in ${instructions.browser}</h3> <ol style="margin: 20px 0; padding-left: 20px;"> ${instructions.steps.map(step => `<li style="margin: 12px 0;">${step}</li>`).join('')} </ol> <div style="display: flex; justify-content: flex-end; gap: 10px;"> <button id="close-modal-btn" style="padding: 8px 16px; background: #2196f3; color: white; border: none; border-radius: 6px; cursor: pointer;">Got it</button> </div> </div> `; { 'event_category': 'user_preferences'
// Initialize after DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', checkAndNotify); } else { checkAndNotify(); }
// Get browser-specific instructions function getBrowserInstructions() { const userAgent = navigator.userAgent.toLowerCase();