Externalize theme-init so the app CSP needs no inline-script hash

This commit is contained in:
Jean Chevronnet 2026-07-21 23:12:59 +00:00
parent f9a1ac016b
commit 5d90c54092
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View file

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content" />
<!-- Apply the saved theme before first paint so there's no flash of the light
default on load/reload. Full theme logic runs later in src/ui/theme.ts. -->
<script>try{var t=localStorage.getItem('tchatou-theme');if(t)document.documentElement.dataset.theme=t;}catch(e){}</script>
<script src="/app/theme-init.js"></script>
<meta name="theme-color" content="#ffffff" />
<link rel="manifest" href="/app/manifest.webmanifest" />
<link rel="icon" href="/app/orbit-icon.svg" type="image/svg+xml" />

5
public/theme-init.js Normal file
View file

@ -0,0 +1,5 @@
// Apply the saved theme before first paint so there's no flash of the light
// default on load/reload. Kept as an external (non-inline) script so the page
// CSP is satisfied by script-src 'self' with no per-script hash to maintain.
// Full theme logic runs later in src/ui/theme.ts.
try { var t = localStorage.getItem('tchatou-theme'); if (t) document.documentElement.dataset.theme = t; } catch (e) {}