55 * Communicates with background service worker via chrome.runtime.sendMessage.
66 */
77
8+ // DIAGNOSTIC: Capture script start time immediately
9+ const POPUP_SCRIPT_START = performance . now ( ) ;
10+ console . log ( "[DIAG] popup script started" ) ;
11+
812import type { UrlDetectionMode } from "@/src/utils/types" ;
913
14+ const diagLog = ( label : string , startTime : number ) => {
15+ const elapsed = Math . round ( performance . now ( ) - startTime ) ;
16+ console . log ( `[DIAG] ${ label } : ${ elapsed } ms` ) ;
17+ } ;
18+
1019interface GetStatusResponse {
1120 mode : UrlDetectionMode ;
1221}
@@ -90,12 +99,19 @@ function populateI18n(): void {
9099 * Initialize popup on DOM ready.
91100 */
92101document . addEventListener ( "DOMContentLoaded" , async ( ) => {
102+ diagLog ( "popup DOMContentLoaded (from script start)" , POPUP_SCRIPT_START ) ;
103+ const t0 = performance . now ( ) ;
104+
93105 // Populate i18n strings first (while loading)
106+ const t1 = performance . now ( ) ;
94107 populateI18n ( ) ;
108+ diagLog ( "popup populateI18n" , t1 ) ;
95109
96110 try {
97111 // Load current mode from background
112+ const t2 = performance . now ( ) ;
98113 const currentMode = await getStatus ( ) ;
114+ diagLog ( "popup getStatus (sendMessage)" , t2 ) ;
99115 updateModeUI ( currentMode ) ;
100116 } catch ( error ) {
101117 // Silent fallback - default to allUrls on error
@@ -108,6 +124,7 @@ document.addEventListener("DOMContentLoaded", async () => {
108124 if ( app ) {
109125 app . classList . remove ( "loading" ) ;
110126 }
127+ diagLog ( "popup DOMContentLoaded.TOTAL" , t0 ) ;
111128
112129 // Bind mode change handlers
113130 document . querySelectorAll < HTMLInputElement > ( 'input[name="detection-mode"]' ) . forEach ( ( radio ) => {
0 commit comments