MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
无编辑摘要 |
||
| 第5行: | 第5行: | ||
style.textContent = ` | style.textContent = ` | ||
@keyframes snowFall { | @keyframes snowFall { | ||
0% { transform: translateY(- | 0% { transform: translateY(-150px) rotate(0deg); } | ||
100% { transform: translateY(100vh) rotate(360deg); } | 100% { transform: translateY(100vh) rotate(360deg); } | ||
} | } | ||
.snowflake { | .snowflake { | ||
position: fixed; | position: fixed; | ||
top: - | top: -150px; // 从-10px改为-150px | ||
z-index: 9999; | z-index: 9999; | ||
pointer-events: none; | pointer-events: none; | ||
| 第24行: | 第24行: | ||
const snowflake = document.createElement('div'); | const snowflake = document.createElement('div'); | ||
snowflake.className = 'snowflake'; | snowflake.className = 'snowflake'; | ||
snowflake.innerHTML = | const icons = ['🍀', '☘️', '🍃']; | ||
const size = Math.random() * 16 + 8; | snowflake.innerHTML = icons[Math.floor(Math.random() * 3)]; | ||
const size = Math.random() * 16 + 8; | |||
const left = Math.random() * 100; | const left = Math.random() * 100; | ||
const duration = Math.random() * 5 + 5; | const duration = Math.random() * 5 + 5; | ||
const delay = Math.random() * 2; | const delay = Math.random() * 2; | ||
snowflake.style.cssText = ` | snowflake.style.cssText = ` | ||
| 第46行: | 第47行: | ||
let interval = setInterval(createSnowflake, | let interval = setInterval(createSnowflake, 400); | ||
| 第62行: | 第63行: | ||
} | } | ||
})(); | })(); | ||
importScript('MediaWiki:Tangle/'+ wgPageName + '.js'); | |||
2025年4月14日 (一) 15:34的版本
(function(){
if (!document.getElementById('snow-style')) {
const style = document.createElement('style');
style.id = 'snow-style';
style.textContent = `
@keyframes snowFall {
0% { transform: translateY(-150px) rotate(0deg); }
100% { transform: translateY(100vh) rotate(360deg); }
}
.snowflake {
position: fixed;
top: -150px; // 从-10px改为-150px
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';
const icons = ['🍀', '☘️', '🍃'];
snowflake.innerHTML = icons[Math.floor(Math.random() * 3)];
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, 400);
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
clearInterval(interval);
} else {
interval = setInterval(createSnowflake, 500);
}
});
for (let i = 0; i < 10; i++) {
createSnowflake();
}
})();
importScript('MediaWiki:Tangle/'+ wgPageName + '.js');