微件:覆盖页面为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('没找到 .citizen-page-container,放弃替换');
return;
}
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.style.width = '100%';
iframe.style.height = '99vh';
iframe.style.border = 'none';
container.parentNode.replaceChild(iframe, container);
} 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>