function tryCelebrate() { const today = new Date(); const date = [today.getMonth() + 1, today.getDate()] switch ((today.getMonth() + 1) * 100 + today.getDate()) { case 831: return startCelebrations('🎂', '.miku', 90); case 1225: return startCelebrations('🎄', '.miku', 90); } const isMilestone = MIKUS.features.length % 500 === 0; if (isMilestone) { let f = startCelebrations('🎉', '#count', 270) count.onclick = count.onmouseover = f; return; } } function startCelebrations(emoji, selector, angle) { function xy(elem) { let vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) let vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0) let { x, y } = elem.getBoundingClientRect() return { 'x': x / vw, 'y': y / vh }; } let cake = $('a') cake.innerText = emoji cake.style = 'cursor: pointer' cake.title = "happy birthday miku!" const title = document.getElementById('title') title.appendChild($space()) title.appendChild(cake) let confettisrc = $('script') confettisrc.src = "https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.3/dist/confetti.browser.min.js"; document.body.appendChild(confettisrc) let N = 0; cake.onclick = () => { let element = document.querySelector(selector); if (!element) return; N += 1; let colors = N % 10 ? ['#3dbdd5'] : undefined; let count = N % 10 ? 20 : 100; let m = showcaseMiku ? showcaseMiku.properties : {}; if (m.name === "Brazil") { count = 100; colors = [ '#009B3A', '#FEDF00', '#002776' ] } confetti({ 'origin': xy(element), 'angle': angle, 'spread': 140, 'particleCount': 100, 'ticks': 100, 'gravity': 0.3, 'colors': colors, 'shapes': ['square'], 'disableForReducedMotion': true, }); } return cake.onclick; }