mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Set night-mode class on web page initialization
Ensures the background is the correct color by the time the webview is shown. We keep the #night check for now, as it's useful when testing in an external browser.
This commit is contained in:
parent
1870253589
commit
93d14de95c
1 changed files with 5 additions and 0 deletions
|
@ -664,6 +664,10 @@ html {{ {font} }}
|
||||||
gui_hooks.webview_did_inject_style_into_page(self)
|
gui_hooks.webview_did_inject_style_into_page(self)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
if theme_manager.night_mode:
|
||||||
|
night_mode = 'document.documentElement.classList.add("night-mode");'
|
||||||
|
else:
|
||||||
|
night_mode = ""
|
||||||
self.evalWithCallback(
|
self.evalWithCallback(
|
||||||
f"""
|
f"""
|
||||||
(function(){{
|
(function(){{
|
||||||
|
@ -671,6 +675,7 @@ html {{ {font} }}
|
||||||
style.innerHTML = `{css}`;
|
style.innerHTML = `{css}`;
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
document.body.classList.add({", ".join([f'"{c}"' for c in body_classes])});
|
document.body.classList.add({", ".join([f'"{c}"' for c in body_classes])});
|
||||||
|
{night_mode}
|
||||||
}})();
|
}})();
|
||||||
""",
|
""",
|
||||||
after_injection,
|
after_injection,
|
||||||
|
|
Loading…
Reference in a new issue