In my background.js, when I use localStorage nothing happens. I think it’s how chrome extension programming works (localStorage doesn’t work in background pages). I can use localStorage in popup page but for what I want to achieve, accessing localStorage in the background page is a must.
So I have two alternatives:
1- Send a request from background to popup page, popup page receive the message and create a localstorage with it, and background page retrieves the value of localstorage from popup page. When the background page sends the request, the popup page must respond instantly (not to except for a click of the user on extension icon).
If it’s possible, how to do it?
2- Find a way to store data in background page like localstorage. If it’s possible, how to do it?
Thanks
You can use localStorage in background pages, the issue may be that background pages are persistent/stored in memory. So, you have to manually reload the extension, not just edit the file.
To manually reload an extension:
Hit: Chrome > Tools > Extensions (“Chrome” is either a wrench or three bars in a stack)
Scroll to the one your working on, hit reload.
Your other option is to install an extension to make this easier instead of having to got to the extensions page every single time. There are a few, such as Quick Extension Reload.