MediaWiki:Common.js
MediaWiki界面页面
更多操作
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
(function() {
if (window.__globalFooterAdded) return;
var footerHtml = '<div id="global-footer-links" style="width:100%; margin-top:20px; padding:15px 0; display:flex; justify-content:space-between; flex-wrap:wrap; gap:10px; border-top:1px solid #ccc;">' +
'<div><a href="https://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' +
'<div><a href="https://www.pvzhe.com/new">前往官网以了解更多游戏信息</a></div>' +
'</div>';
function insertFooter() {
if (document.getElementById('global-footer-links')) return true;
// 优先查找手机端页脚(Minerva 常见结构)
var mobileFooter = document.querySelector('.mw-footer-container, .minerva-footer, footer');
if (mobileFooter) {
mobileFooter.insertAdjacentHTML('beforebegin', footerHtml);
window.__globalFooterAdded = true;
return true;
}
// 备选:PC 端页脚
var pcFooter = document.querySelector('#footer, #mw-footer, .footer');
if (pcFooter) {
pcFooter.insertAdjacentHTML('beforebegin', footerHtml);
window.__globalFooterAdded = true;
return true;
}
// 最后备选:内容区末尾
var content = document.querySelector('#mw-content-text, .mw-body-content, #content, .mw-body');
if (content) {
content.insertAdjacentHTML('beforeend', footerHtml);
window.__globalFooterAdded = true;
return true;
}
return false;
}
// 执行插入
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(insertFooter, 200);
});
} else {
setTimeout(insertFooter, 200);
}
// 监听动态加载内容(如手机端的无限滚动)
var observer = new MutationObserver(function() {
if (!window.__globalFooterAdded) insertFooter();
});
observer.observe(document.body, { childList: true, subtree: true });
setTimeout(function() { observer.disconnect(); }, 8000);
})();