MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
(function() { | (function(){ | ||
// 全局雪花容器 | |||
window.snowflakes = window.snowflakes || []; | |||
// 核心动画引擎 | |||
function createSnow(){ | |||
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); | |||
setTimeout(() => { setInterval(spawn, 3000) }, 10000); | |||
} | |||
// 动态样式注入 | |||
if(!document.getElementById('snowStyle')){ | |||
const style = document.createElement('style'); | |||
style.id = 'snowStyle'; | |||
style.textContent = `@keyframes snowFall { | |||
0%{transform:translateY(-30px) rotate(0deg)} | |||
100%{transform:translateY(120vh) rotate(720deg)} | |||
}`; | |||
document.head.appendChild(style); | document.head.appendChild(style); | ||
} | |||
// 自动恢复机制 | |||
document.addEventListener('visibilitychange', () => { | |||
if(!document.hidden && snowflakes.length < 20) createSnow(); | |||
}); | |||
// 初始启动 | |||
createSnow(); | |||
})(); | })(); | ||
2025年4月14日 (一) 05:42的版本
(function(){
// 全局雪花容器
window.snowflakes = window.snowflakes || [];
// 核心动画引擎
function createSnow(){
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);
setTimeout(() => { setInterval(spawn, 3000) }, 10000);
}
// 动态样式注入
if(!document.getElementById('snowStyle')){
const style = document.createElement('style');
style.id = 'snowStyle';
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();
})();