微件:覆盖页面为URL
来自EaseCation Wiki
更多操作
请使用 公民 皮肤浏览
<script> (function() {
function isDomain(url) {
try {
const urlObj = new URL(url);
const hostname = urlObj.hostname.toLowerCase();
return hostname === 'easecation.net' ||
hostname.endsWith('.easecation.net');
} catch (error) {
return false;
}
}
const script = document.currentScript || (function() {
const scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
const url = "";
if (isDomain(url)) {
const container = document.querySelector('.citizen-page-container');
if (!container) {
console.warn('没找到标签,放弃替换');
return;
}
// 创建 main 包裹层
const main = document.createElement('main');
main.className = 'mw-body ve-init-mw-desktopArticleTarget-targetContainer';
main.id = 'content';
// 创建 iframe
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.style.width = '100%';
iframe.style.height = '99vh';
iframe.style.border = 'none';
// 组装结构:iframe → main → container
main.appendChild(iframe);
container.innerHTML = ; // 清空原内容
container.appendChild(main);
const style = document.createElement('style');
style.textContent = `
.citizen-page-container > .banner-image,
.citizen-page-container > .mw-footer,
.citizen-page-container > .citizen-footer {
display: none !important;
}
`;
document.head.appendChild(style);
} else {
const info = document.getElementById('iframe-info');
if (info) {
info.innerHTML = '只允许嵌入 easecation.net 的页面';
}
}
})();
const citizenLink = document.getElementById('citizen-link'); if (citizenLink) {
citizenLink.addEventListener('click', function() {
const url = new URL(location.href);
url.searchParams.set('useskin', 'citizen');
location.href = url.href;
});
} </script>