55 * the toolbar badge with the cache status (HIT/MISS/etc).
66 */
77
8+ // =============================================================================
9+ // Icon Paths
10+ // =============================================================================
11+
12+ const DEFAULT_ICON = {
13+ 16 : 'images/icon-16.png' ,
14+ 32 : 'images/icon-32.png' ,
15+ 48 : 'images/icon-48.png' ,
16+ 128 : 'images/icon-128.png'
17+ } ;
18+
19+ const PENDING_ICON = {
20+ 16 : 'images/icon-pending-16.png' ,
21+ 32 : 'images/icon-pending-32.png' ,
22+ 48 : 'images/icon-pending-48.png' ,
23+ 128 : 'images/icon-pending-128.png'
24+ } ;
25+
826// =============================================================================
927// State Management
1028// =============================================================================
@@ -37,10 +55,13 @@ function updateBadge(tabId, status) {
3755 const badgeText = status ? ( badgeTextMap [ status . toUpperCase ( ) ] || status ) : '' ;
3856 const color = status === 'HIT' ? '#34C759' : status === 'MISS' ? '#FF3B30' : '#8E8E93' ;
3957
58+ // Reset to default icon
59+ browser . action . setIcon ( { path : DEFAULT_ICON } ) ;
4060 browser . action . setBadgeText ( { text : badgeText } ) ;
4161 browser . action . setBadgeBackgroundColor ( { color } ) ;
4262
4363 try {
64+ browser . action . setIcon ( { path : DEFAULT_ICON , tabId } ) ;
4465 browser . action . setBadgeText ( { text : badgeText , tabId } ) ;
4566 browser . action . setBadgeBackgroundColor ( { color, tabId } ) ;
4667 } catch ( e ) {
@@ -49,8 +70,19 @@ function updateBadge(tabId, status) {
4970}
5071
5172function clearBadge ( tabId ) {
73+ browser . action . setIcon ( { path : DEFAULT_ICON } ) ;
5274 browser . action . setBadgeText ( { text : '' } ) ;
5375 try {
76+ browser . action . setIcon ( { path : DEFAULT_ICON , tabId } ) ;
77+ browser . action . setBadgeText ( { text : '' , tabId } ) ;
78+ } catch ( e ) { }
79+ }
80+
81+ function showPendingIcon ( tabId ) {
82+ browser . action . setIcon ( { path : PENDING_ICON } ) ;
83+ browser . action . setBadgeText ( { text : '' } ) ;
84+ try {
85+ browser . action . setIcon ( { path : PENDING_ICON , tabId } ) ;
5486 browser . action . setBadgeText ( { text : '' , tabId } ) ;
5587 } catch ( e ) { }
5688}
@@ -109,13 +141,8 @@ browser.webNavigation.onCompleted.addListener((details) => {
109141 } ) ;
110142 }
111143
112- // Show reload badge
113- browser . action . setBadgeText ( { text : 'RLD' } ) ;
114- browser . action . setBadgeBackgroundColor ( { color : '#8E8E93' } ) ;
115- try {
116- browser . action . setBadgeText ( { text : 'RLD' , tabId : details . tabId } ) ;
117- browser . action . setBadgeBackgroundColor ( { color : '#8E8E93' , tabId : details . tabId } ) ;
118- } catch ( e ) { }
144+ // Show pending icon (cloud with question mark)
145+ showPendingIcon ( details . tabId ) ;
119146
120147 notifyPopup ( details . tabId ) ;
121148 }
@@ -205,7 +232,11 @@ browser.tabs.onRemoved.addListener((tabId) => {
205232browser . tabs . onActivated . addListener ( ( activeInfo ) => {
206233 const data = tabData . get ( activeInfo . tabId ) ;
207234 if ( data ) {
208- updateBadge ( activeInfo . tabId , data . status ) ;
235+ if ( data . noHeaders ) {
236+ showPendingIcon ( activeInfo . tabId ) ;
237+ } else {
238+ updateBadge ( activeInfo . tabId , data . status ) ;
239+ }
209240 } else {
210241 clearBadge ( activeInfo . tabId ) ;
211242 }
@@ -221,7 +252,11 @@ browser.windows.onFocusChanged.addListener(async (windowId) => {
221252 if ( tabs ?. [ 0 ] ) {
222253 const data = tabData . get ( tabs [ 0 ] . id ) ;
223254 if ( data ) {
224- updateBadge ( tabs [ 0 ] . id , data . status ) ;
255+ if ( data . noHeaders ) {
256+ showPendingIcon ( tabs [ 0 ] . id ) ;
257+ } else {
258+ updateBadge ( tabs [ 0 ] . id , data . status ) ;
259+ }
225260 } else {
226261 clearBadge ( tabs [ 0 ] . id ) ;
227262 }
0 commit comments