Restore robust window.parent theme detection for instant iframe styling
This commit is contained in:
@@ -207,8 +207,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function(){
|
(function(){
|
||||||
|
let isLight = false;
|
||||||
|
try {
|
||||||
|
isLight = !window.parent.document.documentElement.classList.contains('dark');
|
||||||
|
} catch (e) {
|
||||||
const p = new URLSearchParams(window.location.search);
|
const p = new URLSearchParams(window.location.search);
|
||||||
window.isLightTheme = p.get('theme') === 'light';
|
isLight = p.get('theme') === 'light';
|
||||||
|
}
|
||||||
|
window.isLightTheme = isLight;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const stage=document.getElementById('stage');
|
const stage=document.getElementById('stage');
|
||||||
@@ -403,9 +409,14 @@
|
|||||||
<script>
|
<script>
|
||||||
(function(){
|
(function(){
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
let isLight = false;
|
||||||
|
try {
|
||||||
|
isLight = !window.parent.document.documentElement.classList.contains('dark');
|
||||||
|
} catch (e) {
|
||||||
const p = new URLSearchParams(window.location.search);
|
const p = new URLSearchParams(window.location.search);
|
||||||
window.isLightTheme = p.get('theme') === 'light';
|
isLight = p.get('theme') === 'light';
|
||||||
const isLight = window.isLightTheme;
|
}
|
||||||
|
window.isLightTheme = isLight;
|
||||||
|
|
||||||
if (isLight) {
|
if (isLight) {
|
||||||
document.body.style.setProperty('background', '#ffffff', 'important');
|
document.body.style.setProperty('background', '#ffffff', 'important');
|
||||||
|
|||||||
@@ -64,8 +64,14 @@ def port_html():
|
|||||||
# Inject theme initialization at start of script block
|
# Inject theme initialization at start of script block
|
||||||
init_theme_script = """<script>
|
init_theme_script = """<script>
|
||||||
(function(){
|
(function(){
|
||||||
|
let isLight = false;
|
||||||
|
try {
|
||||||
|
isLight = !window.parent.document.documentElement.classList.contains('dark');
|
||||||
|
} catch (e) {
|
||||||
const p = new URLSearchParams(window.location.search);
|
const p = new URLSearchParams(window.location.search);
|
||||||
window.isLightTheme = p.get('theme') === 'light';
|
isLight = p.get('theme') === 'light';
|
||||||
|
}
|
||||||
|
window.isLightTheme = isLight;
|
||||||
})();
|
})();
|
||||||
"""
|
"""
|
||||||
html = html.replace("<script>", init_theme_script, 1)
|
html = html.replace("<script>", init_theme_script, 1)
|
||||||
@@ -106,9 +112,14 @@ def port_html():
|
|||||||
<script>
|
<script>
|
||||||
(function(){
|
(function(){
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
let isLight = false;
|
||||||
|
try {
|
||||||
|
isLight = !window.parent.document.documentElement.classList.contains('dark');
|
||||||
|
} catch (e) {
|
||||||
const p = new URLSearchParams(window.location.search);
|
const p = new URLSearchParams(window.location.search);
|
||||||
window.isLightTheme = p.get('theme') === 'light';
|
isLight = p.get('theme') === 'light';
|
||||||
const isLight = window.isLightTheme;
|
}
|
||||||
|
window.isLightTheme = isLight;
|
||||||
|
|
||||||
if (isLight) {
|
if (isLight) {
|
||||||
document.body.style.setProperty('background', '#ffffff', 'important');
|
document.body.style.setProperty('background', '#ffffff', 'important');
|
||||||
|
|||||||
Reference in New Issue
Block a user