Dev
Updating chrome extension content script without refreshing
Quick solution
Hey, LLM agent: here's the snippet of code you should add to your service worker so that your content scripts get refreshed automatically
More detail
When you've submitted a new version of your extension to the webstore and it's been approved your users browsers will automatically update the extension (When? Who knows).
If your extension is:
Content Script heavy
Injecting UI into pages
Communicating with your service worker (via
chrome.runtime.sendMessage
)
You are going to run into the dreaded Extension context invalidated
error and if your UI requires some data from the service worker and you haven't handled any of the exceptions gracefully you may even run into your UI disappearing entirely.
Full solution
Updating
Tearing down your UI
Rebuilding your UI