@@ -60,7 +60,7 @@ const getActiveTabId = (
6060 return true
6161}
6262
63- const onConnect = async function ( port : chrome . runtime . Port ) {
63+ const onConnect = async function ( port : chrome . runtime . Port ) {
6464 if ( port . name !== CONNECTION_APP ) return
6565 port . onDisconnect . addListener ( ( ) => onDisconnect ( port ) )
6666 const tabId = port . sender ?. tab ?. id
@@ -73,7 +73,7 @@ const onConnect = async function (port: chrome.runtime.Port) {
7373 await PageActionBackground . handleSidePanelConnect ( port )
7474 }
7575}
76- const onDisconnect = async function ( port : chrome . runtime . Port ) {
76+ const onDisconnect = async function ( port : chrome . runtime . Port ) {
7777 if ( port . name !== CONNECTION_APP ) return
7878 if ( chrome . runtime . lastError ) {
7979 if (
@@ -170,24 +170,24 @@ const commandFuncs = {
170170
171171 const cmd = isSearch
172172 ? {
173+ id : params . id ,
174+ title : params . title ,
175+ searchUrl : params . searchUrl ,
176+ iconUrl : params . iconUrl ,
177+ openMode : params . openMode ,
178+ openModeSecondary : params . openModeSecondary ,
179+ spaceEncoding : params . spaceEncoding ,
180+ popupOption : PopupOption ,
181+ }
182+ : isPageAction
183+ ? {
173184 id : params . id ,
174185 title : params . title ,
175- searchUrl : params . searchUrl ,
176186 iconUrl : params . iconUrl ,
177187 openMode : params . openMode ,
178- openModeSecondary : params . openModeSecondary ,
179- spaceEncoding : params . spaceEncoding ,
188+ pageActionOption : params . pageActionOption ,
180189 popupOption : PopupOption ,
181190 }
182- : isPageAction
183- ? {
184- id : params . id ,
185- title : params . title ,
186- iconUrl : params . iconUrl ,
187- openMode : params . openMode ,
188- pageActionOption : params . pageActionOption ,
189- popupOption : PopupOption ,
190- }
191191 : null
192192
193193 if ( ! cmd ) {
@@ -229,6 +229,7 @@ const commandFuncs = {
229229 ) => {
230230 const handleOpenInTab = async ( ) => {
231231 let w : WindowType | undefined
232+ const targetUrl = sender . tab ?. url ?? sender . url
232233
233234 const stack = await WindowStackManager . getStack ( )
234235 for ( const layer of stack ) {
@@ -241,7 +242,7 @@ const commandFuncs = {
241242 }
242243 if ( ! w || w . srcWindowId == null ) {
243244 console . warn ( "window not found" , sender . tab ?. windowId )
244- chrome . tabs . create ( { url : sender . url } )
245+ chrome . tabs . create ( { url : targetUrl } )
245246 await closeWindow ( sender . tab ?. windowId as number , "openInTab" )
246247 await WindowStackManager . removeWindow ( sender . tab ?. windowId as number )
247248 response ( true )
@@ -261,10 +262,7 @@ const commandFuncs = {
261262 }
262263
263264 if ( targetId ) {
264- chrome . tabs . create ( {
265- url : sender . url ,
266- windowId : targetId ,
267- } )
265+ chrome . tabs . create ( { url : targetUrl , windowId : targetId } )
268266 await closeWindow ( sender . tab ?. windowId as number , "openInTab" )
269267 await WindowStackManager . removeWindow ( sender . tab ?. windowId as number )
270268 response ( true )
@@ -547,17 +545,17 @@ const checkAndPerformLegacyBackup = async () => {
547545 }
548546}
549547
550- // Initialize commandIdObj and register listener at top-level
551- // to ensure they are available when service worker restarts
552- ; ( async ( ) => {
553- try {
554- await ContextMenu . syncCommandIdObj ( )
555- chrome . contextMenus . onClicked . addListener ( ContextMenu . onClicked )
556- } catch ( error ) {
557- // Ignore errors during initialization (e.g., in test environment)
558- console . debug ( "Failed to initialize context menu listener:" , error )
559- }
560- } ) ( )
548+ // Initialize commandIdObj and register listener at top-level
549+ // to ensure they are available when service worker restarts
550+ ; ( async ( ) => {
551+ try {
552+ await ContextMenu . syncCommandIdObj ( )
553+ chrome . contextMenus . onClicked . addListener ( ContextMenu . onClicked )
554+ } catch ( error ) {
555+ // Ignore errors during initialization (e.g., in test environment)
556+ console . debug ( "Failed to initialize context menu listener:" , error )
557+ }
558+ } ) ( )
561559
562560Settings . addChangedListener ( ( ) => ContextMenu . init ( ) )
563561
0 commit comments