MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
(function() { | (function() { | ||
if (window.__globalFooterAdded) return; | |||
if (window.__globalFooterAdded) | |||
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;">' + | 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://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' + | ||
| 第11行: | 第7行: | ||
'</div>'; | '</div>'; | ||
function insertFooter() { | function insertFooter() { | ||
if (document.getElementById('global-footer-links')) return true; | |||
if (document.getElementById('global-footer-links')) { | |||
// 优先查找手机端页脚(Minerva 常见结构) | |||
var mobileFooter = document.querySelector('.mw-footer-container, .minerva-footer, footer'); | |||
if (mobileFooter) { | |||
mobileFooter.insertAdjacentHTML('beforebegin', footerHtml); | |||
window.__globalFooterAdded = true; | |||
return true; | return true; | ||
} | } | ||
// | // 备选:PC 端页脚 | ||
var | var pcFooter = document.querySelector('#footer, #mw-footer, .footer'); | ||
if ( | if (pcFooter) { | ||
pcFooter.insertAdjacentHTML('beforebegin', footerHtml); | |||
window.__globalFooterAdded = true; | window.__globalFooterAdded = true; | ||
return true; | return true; | ||
} | } | ||
// | // 最后备选:内容区末尾 | ||
var content = document.querySelector('#mw-content-text, .mw-body-content, #content'); | var content = document.querySelector('#mw-content-text, .mw-body-content, #content, .mw-body'); | ||
if (content) { | if (content) { | ||
content.insertAdjacentHTML('beforeend', footerHtml); | content.insertAdjacentHTML('beforeend', footerHtml); | ||
| 第37行: | 第37行: | ||
} | } | ||
// | // 执行插入 | ||
if (document.readyState === 'loading') { | if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
setTimeout(insertFooter, 200); | |||
setTimeout( | |||
}); | }); | ||
} else { | } else { | ||
setTimeout( | 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); | |||
})(); | })(); | ||
2026年3月22日 (日) 05:37的版本
(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);
})();