electron-browser-shell icon indicating copy to clipboard operation
electron-browser-shell copied to clipboard

[electron-chrome-extensions] event for chrome.tabs.update

Open Kilian opened this issue 2 years ago • 2 comments

One of my extensions calles chrome.tabs.update with a new URL like so:

const openInSuperposition = url => chrome.tabs.update({ url: `superposition://${url}` });

I'd like to be able to hook into that call and decide how to update or handle that URL change. Is that possible?

Kilian avatar Jan 20 '23 12:01 Kilian

Looking into this, it seems that because I dont provide a tabId, the current implementation picks the webcontents of the sender as the active tab but if that's not added to the extension manager (in my case, the main UI) then getting the tabid returns undefined and the chrome.tabs.update function is aborted:

https://github.com/samuelmaddock/electron-browser-shell/blob/master/packages/electron-chrome-extensions/src/browser/api/tabs.ts#L257

Is there a way to fall back to whatever webContents was last selected with selectExtensionTab?

Kilian avatar Mar 24 '23 16:03 Kilian

I had a bug in the code which was trying to get the active tab from the window of the MV2 background page. I updated the code to get the active tab from the last focused window instead.

samuelmaddock avatar Jun 03 '23 05:06 samuelmaddock