MediaWiki:Common.js
来自Fuckrooms Wiki
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
(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(); })();