MediaWiki:Common.js:修订间差异

来自Fuckrooms Wiki
无编辑摘要
无编辑摘要
第2行: 第2行:
(function(){
(function(){


window.snowflakes = window.snowflakes || [];
window.leaves = window.leaves || [];




function createSnow(){
if(!document.getElementById('leafStyle')){
     const chars = ['','','❆','✦'];
     const style = document.createElement('style');
      
    style.id = 'leafStyle';
    function spawn(){
     style.textContent = `
         const flake = document.createElement('div');
        @keyframes leafFall {
         flake.style = `position:fixed;top:-30px;color:#fff;z-index:9999;
            0%{ transform: translate(-20vw, -50px) rotate(0deg) }
             pointer-events:none;user-select:none;font-size:${Math.random()*15+10}px;
            100%{ transform: translate(20vw, 120vh) rotate(1080deg) }
             left:${Math.random()*100}%;opacity:${Math.random()*0.5+0.5};
         }
             animation:snowFall ${Math.random()*8+5}s linear infinite`;
         .leaf {
         flake.textContent = chars[Math.floor(Math.random()*chars.length)];
            position: fixed;
        document.body.appendChild(flake);
            z-index: 99999;
        snowflakes.push(flake);
             pointer-events: none;
    }
            font-size: 24px;
             opacity: 0.8;
             text-shadow: 1px 1px 2px #333;
         }
    `;
    document.head.appendChild(style);
}
 


      
function createLeaf(){
     setInterval(spawn, 500);
    const leaf = document.createElement('div');
    setTimeout(() => { setInterval(spawn, 3000) }, 10000);
    leaf.className = 'leaf';
     leaf.innerHTML = '🍃'; // 使用树叶符号
     leaf.style.cssText = `
        left: ${Math.random() * 100}%;
        color: ${['#8BC34A','#4CAF50','#388E3C'][Math.floor(Math.random()*3)]};
        animation: leafFall ${8 + Math.random()*12}s cubic-bezier(0.4,0,0.6,1) infinite;
        filter: hue-rotate(${Math.random()*60}deg);
    `;
    document.body.appendChild(leaf);
    leaves.push(leaf);
}
}




if(!document.getElementById('snowStyle')){
function startFall(){
    const style = document.createElement('style');
    setInterval(() => {
     style.id = 'snowStyle';
        if(leaves.length < 50) {
     style.textContent = `@keyframes snowFall {
            createLeaf();
         0%{transform:translateY(-30px) rotate(0deg)}
            if(Math.random() > 0.8) createLeaf(); // 随机双倍生成
        100%{transform:translateY(120vh) rotate(720deg)}
        }
    }`;
     }, 800);
     document.head.appendChild(style);
      
   
    setInterval(() => {
         leaves = leaves.filter(leaf => {
            if(leaf.getBoundingClientRect().top > window.innerHeight*1.2){
                leaf.remove();
                return false;
            }
            return true;
        });
     }, 5000);
}
}




document.addEventListener('visibilitychange', () => {
document.addEventListener('visibilitychange', () => {
     if(!document.hidden && snowflakes.length < 20) createSnow();
     if(!document.hidden) startFall();
});
});




createSnow();
startFall();
})();
})();

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


(function(){

window.leaves = window.leaves || [];


if(!document.getElementById('leafStyle')){
    const style = document.createElement('style');
    style.id = 'leafStyle';
    style.textContent = `
        @keyframes leafFall {
            0%{ transform: translate(-20vw, -50px) rotate(0deg) }
            100%{ transform: translate(20vw, 120vh) rotate(1080deg) }
        }
        .leaf {
            position: fixed;
            z-index: 99999;
            pointer-events: none;
            font-size: 24px;
            opacity: 0.8;
            text-shadow: 1px 1px 2px #333;
        }
    `;
    document.head.appendChild(style);
}


function createLeaf(){
    const leaf = document.createElement('div');
    leaf.className = 'leaf';
    leaf.innerHTML = '🍃'; // 使用树叶符号
    leaf.style.cssText = `
        left: ${Math.random() * 100}%;
        color: ${['#8BC34A','#4CAF50','#388E3C'][Math.floor(Math.random()*3)]};
        animation: leafFall ${8 + Math.random()*12}s cubic-bezier(0.4,0,0.6,1) infinite;
        filter: hue-rotate(${Math.random()*60}deg);
    `;
    document.body.appendChild(leaf);
    leaves.push(leaf);
}


function startFall(){
    setInterval(() => {
        if(leaves.length < 50) {
            createLeaf();
            if(Math.random() > 0.8) createLeaf(); // 随机双倍生成
        }
    }, 800);
    
    
    setInterval(() => {
        leaves = leaves.filter(leaf => {
            if(leaf.getBoundingClientRect().top > window.innerHeight*1.2){
                leaf.remove();
                return false;
            }
            return true;
        });
    }, 5000);
}


document.addEventListener('visibilitychange', () => {
    if(!document.hidden) startFall();
});


startFall();
})();