···10081008 console.error('[page] Load failed:', e.errorCode, e.errorDescription);
10091009});
1010101010111011-// Detect page background color, set it as backing color on the webview element,
10121012-// then fade the webview in. This prevents the white flash when loading pages in dark mode.
10111011+// On dom-ready: clear loading glow immediately, then detect page background color.
10121012+// Background detection prevents the white flash when loading pages in dark mode.
10131013webview.addEventListener('dom-ready', async () => {
10141014- // Always end loading state — even if background detection fails
10151015- const endLoading = () => {
10161016- webview.classList.add('ready');
10171017- webview.classList.remove('loading');
10181018- if (showSource === 'loading') {
10191019- scheduleHide();
10201020- }
10211021- };
10141014+ // End loading state IMMEDIATELY — don't wait for async bg detection.
10151015+ // This MUST be synchronous at the top of dom-ready so the glow always
10161016+ // clears promptly, even if executeJavaScript hangs or never resolves.
10171017+ webview.classList.add('ready');
10181018+ webview.classList.remove('loading');
10191019+ if (showSource === 'loading') {
10201020+ scheduleHide();
10211021+ }
10221022+ DEBUG && console.log('[page] dom-ready: loading glow cleared');
1022102310241024+ // Detect background color (cosmetic — must not block loading state)
10231025 try {
10241026 const bgResult = await webview.executeJavaScript(`
10251027 (function() {
···10661068 } catch (err) {
10671069 console.error('[page] Failed to detect background:', err);
10681070 }
10691069-10701070- endLoading();
10711071});
1072107210731073// Re-add loading glow on new navigations (but keep webview visible — don't reset opacity)