MediaWiki:Common.js:修订间差异

来自赛尔号精灵图鉴
跳转到导航 跳转到搜索
无编辑摘要
Len留言 | 贡献
无编辑摘要
第1行: 第1行:
mw.loader.using('mediawiki.util', function () {
const audio = document.createElement('audio');
  const audio = document.createElement('audio');
audio.src = 'https://d1rtq9slcl72gh.cloudfront.net/audio/home.mp3';
  audio.src = 'https://d1rtq9slcl72gh.cloudfront.net/audio/home.mp3';
audio.loop = true;
  audio.loop = true;
audio.id = 'bgm';
  audio.id = 'bgm';


  const player = document.createElement('div');
const player = document.createElement('div');
  player.innerHTML = `
player.innerHTML = `
    <button onclick="document.getElementById('bgm').play()">▶ 播放</button>
  <button onclick="document.getElementById('bgm').play()">▶</button>
    <button onclick="document.getElementById('bgm').pause()">⏸ 暂停</button>
  <button onclick="document.getElementById('bgm').pause()">⏸</button>
    <div style="flex-grow:1; height:6px; background:#444; border-radius:3px; overflow:hidden;"><div id="bar" style="height:6px;width:0%;background:#66f;"></div></div>
`;
  `;
player.style.cssText = 'position:fixed;bottom:10px;right:10px;z-index:9999;background:#222;padding:10px;border-radius:8px';
  player.style.cssText = "position:fixed;bottom:10px;right:10px;z-index:9999;background:#111;color:white;padding:10px 15px;border-radius:10px;display:flex;gap:10px;align-items:center;box-shadow:0 0 10px #000;font-size:14px";


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


  setInterval(function(){
document.body.addEventListener('click', () => {
    if (!audio.duration) return;
  audio.play().catch(() => {});
    const percent = (audio.currentTime / audio.duration) * 100;
}, { once: true });
    document.getElementById('bar').style.width = percent + '%';
  }, 300);
});

2025年6月4日 (三) 23:36的版本

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 });