37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
(function() {
|
|
if (!document.body.classList.contains('festive-advent') && !document.body.classList.contains('festive-christmas')) {
|
|
return;
|
|
}
|
|
|
|
const snowflakes = ['❄', '❅', '❆', '✻', '✼', '❉', '❋'];
|
|
const container = document.createElement('div');
|
|
container.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9999;overflow:hidden;';
|
|
document.body.appendChild(container);
|
|
|
|
const style = document.createElement('style');
|
|
style.textContent = `
|
|
@keyframes fall {
|
|
to { transform: translateY(120vh) rotate(360deg); }
|
|
}
|
|
`;
|
|
document.head.appendChild(style);
|
|
|
|
function createSnowflake() {
|
|
const flake = document.createElement('div');
|
|
flake.textContent = snowflakes[Math.floor(Math.random() * snowflakes.length)];
|
|
flake.style.cssText = `
|
|
position: absolute;
|
|
left: ${Math.random() * 100}vw;
|
|
top: -50px;
|
|
font-size: ${15 + Math.random() * 20}px;
|
|
color: #fff;
|
|
opacity: ${0.6 + Math.random() * 0.4};
|
|
animation: fall ${8 + Math.random() * 10}s linear;
|
|
`;
|
|
container.appendChild(flake);
|
|
|
|
setTimeout(() => flake.remove(), 18000);
|
|
}
|
|
|
|
setInterval(createSnowflake, 200);
|
|
})(); |