Chrome.SidePanel on close/suspend/unload event

1,013 views
Skip to first unread message

Estefania Chavez Guardado

unread,
Jul 20, 2023, 6:30:18 AM7/20/23
to Chromium Extensions
Hi,

We are having issues to identify an event or way to find out whenever the sidepanel has been closed, the window has been closed or the tab has been closed. We don't want to inject content script. We need only to display a simple browser alert when this happens.

Does anyone has experience with it?

Thanks in advance and have a nice day :)
Estefania

wOxxOm

unread,
Jul 20, 2023, 10:12:25 AM7/20/23
to Chromium Extensions, Estefania Chavez Guardado
Open a port via chrome.runtime.connect from the side panel and listen to its onDisconnect event in the service worker or in the offscreen document. You'll need to keep the recipient context alive e.g. by sending a dummy message through the port every 20 seconds.

Uladzimir Yankovich

unread,
Jul 21, 2023, 12:02:01 PM7/21/23
to Chromium Extensions, wOxxOm, Estefania Chavez Guardado
This will only work if they don't care when their app is hidden (the user has activated another side panel app).

Estefania Chavez Guardado

unread,
Jul 24, 2023, 3:51:21 AM7/24/23
to Chromium Extensions, wOxxOm, Estefania Chavez Guardado
Hi, thank you for your help! We were able to listen to those events :) 
Reply all
Reply to author
Forward
0 new messages