注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- 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');
// 维护开始时间戳(2025-04-05 03:00:00 UTC)
// MediaWiki:Common.js (安全增强版)
'use strict';
const startTimestamp = 1743793200;
function updateMaintenanceTimer() {
const safeElement = document.getElementById("maintenance-timer");
if (!safeElement) return;
const now = Math.floor(Date.now() / 1000);
const duration = now - startTimestamp;
// 使用模板字符串防止注入
safeElement.textContent = `距离本赛季已维护${
Math.floor(duration / 86400)}天${
Math.floor((duration % 86400) / 3600)}时${
Math.floor((duration % 3600) / 60)}分${
duration % 60}秒`;
}
// 更新页面显示
const timerElement = document.getElementById("maintenance-timer");
if (timerElement) {
timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`;
}
}
// 首次加载更新
updateMaintenanceTimer();
// 每秒刷新
setInterval(updateMaintenanceTimer, 1000);