File tree Expand file tree Collapse file tree
app/service/service_worker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,8 @@ export class ValueService {
126126 }
127127 // 推送到所有加载了本脚本的tab中
128128 for ( const tab of tabs ) {
129- const tabId = tab . id ! ;
129+ const tabId = tab . id ;
130+ if ( tab . discarded || ! tabId ) continue ;
130131 this . popup ! . getScriptMenu ( tabId ) . then ( ( scriptMenu ) => {
131132 if ( scriptMenu . find ( ( item ) => item . storageName === storageName ) ) {
132133 this . runtime ! . sendMessageToTab (
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ export function parseStorageValue(str: string): unknown {
8282export async function getCurrentTab ( ) : Promise < chrome . tabs . Tab | undefined > {
8383 // `tab` will either be a `tabs.Tab` instance or `undefined`.
8484 const [ tab ] = await chrome . tabs . query ( { active : true , lastFocusedWindow : true , windowType : "normal" } ) ;
85+ if ( tab ?. discarded ) return undefined ;
8586 return tab ;
8687}
8788
You can’t perform that action at this time.
0 commit comments