update
This commit is contained in:
parent
a68d52d5b2
commit
77bdb498d9
3 changed files with 14 additions and 90 deletions
|
|
@ -265,52 +265,13 @@ function renderIframe(rel) {
|
|||
const doc = iframe.contentDocument;
|
||||
const style = doc.createElement("style");
|
||||
style.textContent = `
|
||||
html,body {
|
||||
background:#0b0b0b;
|
||||
color:#e6e3d7;
|
||||
font-family:Inter,sans-serif;
|
||||
margin:0;
|
||||
padding:3vh 6vw;
|
||||
line-height:1.8;
|
||||
}
|
||||
body {
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
align-items:center;
|
||||
justify-content:flex-start;
|
||||
min-height:100vh;
|
||||
}
|
||||
* {
|
||||
max-width:960px;
|
||||
width:100%;
|
||||
}
|
||||
img,video,iframe {
|
||||
max-width:100%;
|
||||
height:auto;
|
||||
border-radius:8px;
|
||||
}
|
||||
/* remove internal scrollbars */
|
||||
html { overflow:hidden; }
|
||||
`;
|
||||
doc.head.appendChild(style);
|
||||
|
||||
// Inject auto-height script with debounce
|
||||
const script = doc.createElement("script");
|
||||
script.textContent = `
|
||||
let timeout;
|
||||
function sendHeight() {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
window.parent.postMessage({ type: 'resizeFrame', height: document.body.scrollHeight + 20 }, '*');
|
||||
}, 100);
|
||||
}
|
||||
new ResizeObserver(sendHeight).observe(document.body);
|
||||
window.addEventListener('load', sendHeight);
|
||||
html,body{background:#0b0b0b;color:#e6e3d7;font-family:Inter,sans-serif;
|
||||
margin:0;padding:2rem;}
|
||||
*{max-width:720px;margin:auto;}
|
||||
img,video,iframe{max-width:100%;height:auto;}
|
||||
`;
|
||||
doc.body.appendChild(script);
|
||||
} catch (e) {
|
||||
console.warn("iframe load error", e);
|
||||
}
|
||||
doc.head.appendChild(style);
|
||||
} catch {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -325,13 +286,4 @@ function renderDefault() {
|
|||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", e => {
|
||||
if (e.data?.type === "resizeFrame") {
|
||||
const iframe = document.querySelector("iframe[src*='" + location.hash.replace(/^#\//, "") + "']");
|
||||
if (iframe) {
|
||||
iframe.style.height = e.data.height + "px";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue