const snowstorm = true; // enable/disable snowstorm let msgPrinted = false; // flag to prevent multiple console messages // function to check and control the snowflakes function toggleSnowflakes() { const snowflakeContainer = document.querySelector('.snow-container'); if (!snowflakeContainer) return; const videoPlayer = document.querySelector('.videoPlayerContainer'); const trailerPlayer = document.querySelector('.youtubePlayerContainer'); const isDashboard = document.body.classList.contains('dashboardDocument'); const hasUserMenu = document.querySelector('#app-user-menu'); // hide snowflakes if video/trailer player is active or dashboard is visible if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) { snowflakeContainer.style.display = 'none'; // hide snowflakes if (!msgPrinted) { console.log('Snowstorm hidden'); msgPrinted = true; } } else { snowflakeContainer.style.display = 'block'; // show snowflakes if (msgPrinted) { console.log('Snowstorm visible'); msgPrinted = false; } } } // observe changes in the DOM const observer = new MutationObserver(toggleSnowflakes); // start observation observer.observe(document.body, { childList: true, // observe adding/removing of child elements subtree: true, // observe all levels of the DOM tree attributes: true // observe changes to attributes (e.g. class changes) }); function createSnowflake() { // Schneeflocken-Container const snowContainer = document.querySelector(".snow-container"); const snowflake = document.createElement("div"); snowflake.classList.add("snowflake"); // Zufällige Größe const size = Math.random() * 10 + 5; // Schneeflocken sind zwischen 5px und 15px groß snowflake.style.width = `${size}px`; snowflake.style.height = `${size}px`; // Zufällige Startposition (nur oben rechts) snowflake.style.top = `${Math.random() * 20 - 10}px`; // Leicht variieren um -10px bis 10px snowflake.style.right = `${Math.random() * 20}px`; // Zufällige Dauer der Animation const flightDuration = Math.random() * 2 + 1; // Sehr schnell: 1-3 Sekunden snowflake.style.animationDuration = `${flightDuration}s`; // Flocke zum Container hinzufügen snowContainer.appendChild(snowflake); // Entfernen der Flocke nach der Animation snowflake.addEventListener("animationend", () => { snowflake.remove(); }); } document.addEventListener('DOMContentLoaded', () => { if (!snowstorm) return; // exit if fireworks are disabled createSnowflake(); // Jede 50ms eine neue Schneeflocke erzeugen setInterval(createSnowflake, 50); });