URLColors
URLColors copied to clipboard
Handle migration from localStorage to chrome.storage
-
Adds this badge for users updating from a manifest V2 version. They need to open the popup for the migration to be completed since the service worker does not have access to localStorage which is where the previous settings live.
-
Once the popup is opened, the migration happens instantly for anyone that has
urlColorPrefs
in localStorage, which indicates they have used a manifest V2 of the extension and have not yet migrated (this is the first time opening the manifest V3 modal). We move values from localStorage to chrome.storage. We delete all localStorage. And then we change the badge icon to indicate a success: -
the green badge icon remains on the extension icon until the next time they open it at which point it goes away
I wanted the green badge to go away when the popup is closed, but there is no way for the serviceWorker to know it closed. I tried sending a message to the serivceWorker from the popup's beforeunloaded
event listener but didn't run into any luck. This solution isn't terrible.