注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
// 引入jQuery计时器插件[6](@ref)
mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js');
// 维护开始时间(示例:2020-09-01 00:00:00 UTC)
// 活动截止时间戳(2025-04-23 23:59:00 UTC+8)
const endTimestamp = Date.parse("2025-04-23T23:59:00+08:00");
function updateCountdown() {
const now = new Date().getTime();
const duration = endTimestamp - now;
if (duration <= 0) {
document.getElementById("timer").innerText = "活动已结束";
return;
}
const days = Math.floor(duration / (1000 * 60 * 60 * 24));
const hours = Math.floor((duration % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((duration % (1000 * 60)) / 1000);
document.getElementById("timer").innerText =
`距离全角色限免结束还有${days}天${hours}时${minutes}分${seconds}秒`;
}
// 每秒更新一次
setInterval(updateCountdown, 1000);