MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
Defaultuser6(留言 | 贡献) mh站庆特别版——“上雨” |
||
| 第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
console.log("Hello World!"); | // console.log("Hello World!"); | ||
/* CSS模板 */ | /* CSS模板 */ | ||
| 第25行: | 第25行: | ||
style.id = 'snow-style'; | style.id = 'snow-style'; | ||
style.textContent = ` | style.textContent = ` | ||
@keyframes | @keyframes snowRise { | ||
0% { transform: translateY( | 0% { transform: translateY(calc(100vh + 130px)) rotate(0deg); } | ||
100% { transform: translateY( | 100% { transform: translateY(-110px) rotate(9000deg); } | ||
} | } | ||
.snowflake { | .snowflake { | ||
position: fixed; | position: fixed; | ||
bottom: -130px; | |||
z-index: 9999; | z-index: 9999; | ||
pointer-events: none; | pointer-events: none; | ||
| 第41行: | 第41行: | ||
} | } | ||
function createSnowflake() { | function createSnowflake() { | ||
const snowflake = document.createElement('div'); | const snowflake = document.createElement('div'); | ||
| 第53行: | 第52行: | ||
font-size: ${size}px; | font-size: ${size}px; | ||
left: ${left}%; | left: ${left}%; | ||
animation: | animation: snowRise ${duration}s linear 1; | ||
opacity: ${Math.random() * 0.5 + 0.5}; | opacity: ${Math.random() * 0.5 + 0.5}; | ||
color: hsl(${Math.random() * 360}, 100%, 90%); | color: hsl(${Math.random() * 360}, 100%, 90%); | ||
`; | `; | ||
snowflake.addEventListener('animationend', function() { | snowflake.addEventListener('animationend', function() { | ||
snowflake.remove(); | snowflake.remove(); | ||
| 第66行: | 第64行: | ||
} | } | ||
let interval = setInterval(createSnowflake, 250); | let interval = setInterval(createSnowflake, 250); | ||
document.addEventListener('visibilitychange', function() { | document.addEventListener('visibilitychange', function() { | ||
if (document.hidden) { | if (document.hidden) { | ||
| 第78行: | 第74行: | ||
}); | }); | ||
for (let i = 0; i < 10; i++) { | for (let i = 0; i < 10; i++) { | ||
createSnowflake(); | createSnowflake(); | ||
} | } | ||
})(); | })(); | ||
2025年8月8日 (五) 12:25的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// console.log("Hello World!");
/* CSS模板 */
(function() {
var importCssDivs = document.querySelectorAll('div.import-css');
importCssDivs.forEach(function(div) {
var cssContent = div.textContent || div.innerText;
if (cssContent) {
var styleTag = document.createElement('style');
styleTag.type = 'text/css';
styleTag.appendChild(document.createTextNode(cssContent));
document.head.appendChild(styleTag);
}
});
})();
/* 落叶特效 */
(function(){
if (!document.getElementById('snow-style')) {
const style = document.createElement('style');
style.id = 'snow-style';
style.textContent = `
@keyframes snowRise {
0% { transform: translateY(calc(100vh + 130px)) rotate(0deg); }
100% { transform: translateY(-110px) rotate(9000deg); }
}
.snowflake {
position: fixed;
bottom: -130px;
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() * 4)];
const size = Math.random() * 16 + 8;
const left = Math.random() * 100;
const duration = Math.random() * 8 + 8;
snowflake.style.cssText = `
font-size: ${size}px;
left: ${left}%;
animation: snowRise ${duration}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, 250);
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
clearInterval(interval);
} else {
interval = setInterval(createSnowflake, 250);
}
});
for (let i = 0; i < 10; i++) {
createSnowflake();
}
})();