async function fetchScript(url) { const corsProxy = 'https://api.allorigins.win/raw?url='; const response = await fetch(corsProxy + encodeURIComponent(url)); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.text(); } function launchConfetti() { return new Promise(resolve => { if (typeof confetti === 'function') { confetti({ particleCount: Math.floor(Math.random() * 70) + 105, spread: Math.random() * 120 + 60, startVelocity: Math.random() * 30 + 30, gravity: Math.random() * 0.24 + 0.48, ticks: Math.floor(Math.random() * 50) + 625, scalar: Math.random() * 0.5 + 0.5, decay: 0.92 + Math.random() * 0.04, origin: { x: Math.random(), y: Math.random() * 0.5 } }); } resolve(); }); } function loadScript(url) { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.src = url; script.onload = resolve; script.onerror = reject; document.head.appendChild(script); }); } async function runConfetti() { try { await loadScript('https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js'); const confettiPromises = Array(20).fill().map(launchConfetti); await Promise.allSettled(confettiPromises); console.log('All confetti launched successfully'); } catch (error) { console.error('Error in runConfetti:', error); } } runConfetti();