MediaWiki:Common.js

来自赛尔号精灵图鉴
Len留言 | 贡献2025年6月4日 (三) 23:36的版本
跳转到导航 跳转到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
const audio = document.createElement('audio');
audio.src = 'https://d1rtq9slcl72gh.cloudfront.net/audio/home.mp3';
audio.loop = true;
audio.id = 'bgm';

const player = document.createElement('div');
player.innerHTML = `
  <button onclick="document.getElementById('bgm').play()">▶</button>
  <button onclick="document.getElementById('bgm').pause()">⏸</button>
`;
player.style.cssText = 'position:fixed;bottom:10px;right:10px;z-index:9999;background:#222;padding:10px;border-radius:8px';

document.body.appendChild(audio);
document.body.appendChild(player);

document.body.addEventListener('click', () => {
  audio.play().catch(() => {});
}, { once: true });