@@ -8,6 +8,7 @@ import { INVALID_URLS } from '@/utils/constants'
88import { CONTEXT_MENU , CONTEXT_MENU_ITEM_TRANSLATE_PAGE } from '@/utils/context-menu'
99import logger from '@/utils/logger'
1010import { bgBroadcastRpc } from '@/utils/rpc'
11+ import { registerBackgroundRpcEvent } from '@/utils/rpc/background-fns'
1112import { isTabValid } from '@/utils/tab'
1213import { registerDeclarativeNetRequestRule } from '@/utils/web-request'
1314
@@ -69,9 +70,8 @@ export default defineBackground(() => {
6970 } )
7071 } )
7172
72- browser . tabs . onUpdated . addListener ( async ( tabId , _changeInfo , tab ) => {
73- logger . info ( 'tab updated' , { tabId, changeInfo : _changeInfo , tab } )
74- unAttachedTabs . delete ( tabId )
73+ browser . tabs . onUpdated . addListener ( async ( tabId , changeInfo , tab ) => {
74+ logger . info ( 'tab updated' , { tabId, changeInfo, tab } )
7575 if ( tab . url ) {
7676 await setPopupStatusBasedOnUrl ( tabId , tab . url )
7777 }
@@ -112,5 +112,9 @@ export default defineBackground(() => {
112112 }
113113 } )
114114
115+ registerBackgroundRpcEvent ( 'ready' , ( tabId ) => {
116+ unAttachedTabs . delete ( tabId )
117+ } )
118+
115119 logger . info ( 'Hello background!' , { id : browser . runtime . id } )
116120} )
0 commit comments