0

I am developing an extension that lets web pages and extensions exchange data. And there's a user scenario like the one below.

  1. User opens a website that matches the content script list.
  2. The user can use the web page normally (The content script and extension were working).
  3. The user disabled the extension.
  4. Webpage must notify the user to enable the extension in order to let the web page function properly.
  5. The user re-enables the extension.
  6. The webpage can reconnect itself to the extension without requiring the user to reload the page.

I've found that when the user disabled the extension, the content script can keep working. And when the user re-enabled the extension. The background will re-inject a new content script to the web page. However, the new content script seems to not have the ability to postMessage to the extension.

How can I retrieve the connection of a disconnected web page to the extension, and destroy the old/orphaned content script to prevent it from working?

PS. By the way, in Chrome. I can listen to onDisconnect event of the port and do clean-up of the content script but I won't get any event from onDisconnect on Safari. Am I doing it wrong?

0 Answers0