| 自定义 JavaScript |
(function () {
// 防重复注入
if (document.getElementById('icp-footer')) return;
// === 1. 上移右下角工具栏,给 ICP 腾空间 ===
const SHIFT_PX = 32; // 上移量,要 >= ICP 条高度
function shiftToolbar() {
const tbar = document.getElementById('config-buttons');
if (tbar && tbar.dataset.icpShifted !== '1') {
tbar.style.bottom = (parseInt(getComputedStyle(tbar).bottom) + SHIFT_PX) + 'px';
tbar.dataset.icpShifted = '1';
}
}
// === 2. 创建 ICP footer ===
const footer = document.createElement('div');
footer.id = 'icp-footer';
footer.style.cssText = 'position:fixed;bottom:0;left:0;right:0;text-align:center;padding:8px 0;background:rgba(0,0,0,0.35);backdrop-filter:blur(4px);font-size:12px;z-index:9999;';
const link = document.createElement('a');
link.href = 'https://beian.miit.gov.cn/';
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.textContent = '皖ICP备2025075833号-1';
link.style.cssText = 'color:#aaa;text-decoration:none;transition:color .2s;';
link.addEventListener('mouseenter', () => link.style.color = '#fff');
link.addEventListener('mouseleave', () => link.style.color = '#aaa');
footer.appendChild(link);
const inject = () => {
shiftToolbar();
if (!document.getElementById('icp-footer')) {
document.body.appendChild(footer);
}
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', inject);
} else {
inject();
}
// SPA 切换后工具栏可能被重置,监听 DOM 变化重新上移
if (window.MutationObserver) {
const mo = new MutationObserver(() => {
const tbar = document.getElementById('config-buttons');
if (tbar && tbar.dataset.icpShifted !== '1') {
shiftToolbar();
}
});
mo.observe(document.documentElement, { childList: true, subtree: true });
}
})();
|
|