MediaWiki:Common.js:修订间差异

来自Fuckrooms Wiki
无编辑摘要
无编辑摘要
第1行: 第1行:


(function(){
(function(){
    if (!document.getElementById('snow-style')) {
        const style = document.createElement('style');
        style.id = 'snow-style';
        style.textContent = `
            @keyframes snowFall {
                0% { transform: translate(-50vw, -100px) rotate(0deg); }
                100% { transform: translate(50vw, 100vh) rotate(720deg); }
            }
            .snowflake {
                position: fixed;
                top: -10px;
                z-index: 9999;
                pointer-events: none;
                user-select: none;
                animation-timing-function: linear;
            }
        `;
        document.head.appendChild(style);
    }


window.snowflakes = window.snowflakes || [];
   
    function createSnowflake() {
        const snowflake = document.createElement('div');
        snowflake.className = 'snowflake';
        snowflake.innerHTML = '🍀';
        const size = Math.random() * 16 + 8; //
        const left = Math.random() * 100;
        const duration = Math.random() * 5 + 5;
        const delay = Math.random() * 2;
        snowflake.style.cssText = `
            font-size: ${size}px;
            left: ${left}%;
            animation: snowFall ${duration}s ${delay}s linear 1;
            opacity: ${Math.random() * 0.5 + 0.5};
            color: hsl(${Math.random() * 360}, 100%, 90%);
        `;


     
        snowflake.addEventListener('animationend', function() {
            snowflake.remove();
        });


function createSnow(){
         document.body.appendChild(snowflake);
    const chars = ['🍀','☘️','🍃','🌿'];
   
    function spawn(){
        const flake = document.createElement('div');
        flake.style = `position:fixed;top:-30px;color:#fff;z-index:9999;
            pointer-events:none;user-select:none;font-size:${Math.random()*15+10}px;
            left:${Math.random()*100}%;opacity:${Math.random()*0.5+0.5};
            animation:snowFall ${Math.random()*8+5}s linear infinite`;
        flake.textContent = chars[Math.floor(Math.random()*chars.length)];
         document.body.appendChild(flake);
        snowflakes.push(flake);
     }
     }


      
      
     setInterval(spawn, 500);
     let interval = setInterval(createSnowflake, 500);
    setTimeout(() => { setInterval(spawn, 3000) }, 10000);
}


   
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            clearInterval(interval);
        } else {
            interval = setInterval(createSnowflake, 500);
        }
    });


if(!document.getElementById('snowStyle')){
   
     const style = document.createElement('style');
     for (let i = 0; i < 10; i++) {
    style.id = 'snowStyle';
        createSnowflake();
    style.textContent = `@keyframes snowFall {
    }
        0%{transform:translateY(-30px) rotate(0deg)}
        100%{transform:translateY(120vh) rotate(720deg)}
    }`;
    document.head.appendChild(style);
}
 
 
document.addEventListener('visibilitychange', () => {
    if(!document.hidden && snowflakes.length < 20) createSnow();
});
 
 
createSnow();
})();
})();

2025年4月14日 (一) 14:22的版本


(function(){
    if (!document.getElementById('snow-style')) {
        const style = document.createElement('style');
        style.id = 'snow-style';
        style.textContent = `
            @keyframes snowFall {
                0% { transform: translate(-50vw, -100px) rotate(0deg); }
                100% { transform: translate(50vw, 100vh) rotate(720deg); }
            }
            .snowflake {
                position: fixed;
                top: -10px;
                z-index: 9999;
                pointer-events: none;
                user-select: none;
                animation-timing-function: linear;
            }
        `;
        document.head.appendChild(style);
    }

    
    function createSnowflake() {
        const snowflake = document.createElement('div');
        snowflake.className = 'snowflake';
        snowflake.innerHTML = '🍀';
        const size = Math.random() * 16 + 8; // 
        const left = Math.random() * 100;
        const duration = Math.random() * 5 + 5; 
        const delay = Math.random() * 2;
        snowflake.style.cssText = `
            font-size: ${size}px;
            left: ${left}%;
            animation: snowFall ${duration}s ${delay}s linear 1;
            opacity: ${Math.random() * 0.5 + 0.5};
            color: hsl(${Math.random() * 360}, 100%, 90%);
        `;

       
        snowflake.addEventListener('animationend', function() {
            snowflake.remove();
        });

        document.body.appendChild(snowflake);
    }

    
    let interval = setInterval(createSnowflake, 500);

    
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            clearInterval(interval);
        } else {
            interval = setInterval(createSnowflake, 500);
        }
    });

    
    for (let i = 0; i < 10; i++) {
        createSnowflake();
    }
})();