Is it possible to store data in a way that will be accessible after a browser restart in the context of a chrome extension?
相关问题
- Browsers render final comma of right-to-left (rtl)
- Chrome dev tools exact computed value for CSS rule
- Change Chromium icon and “chrome” text to custom i
- debugging webgl in chrome
- Shadow DOM CSS Styling from outside is not working
相关文章
- Is there a way to hide the new HTML5 spinbox contr
- Google Chrome Cache
- how to download a file on Chrome without auto rena
- Do all browsers on iOS use WKWebview or UIWebVIew?
- Why does Google Chrome NOT use cached pages when I
- Calling Chrome web browser from the webbrowser.get
- localStorage data persistence
- Progressive web app(PWA) vs Electron vs Browser ex
even simpler than that:
to read:
to write:
to get rid of:
Nowadays it might be better to use chrome.storage chrome.storage is asynchronous, which makes it faster and localStorage is limited to 5MB.
Yes, it is. Going over a full walkthrough of how to do this would probably exceed the length of a reasonable StackOverflow answer, so I'll refer you to this very extensive tutorial by Rajdeep Dua.
The relevant code would look like this:
The current chrome version has local storage.
I have used it myself. You can use modernizr to detect whether the browser supports it or not. I have written a solution for a client where I do a fallback to cookie if no local storage exists, but this shouldn't be a problem for extensions.
Chrome also supports the HTML5 Web Database spec. This gives you a local SQL database, so you can do more complex things than simply storing name/value pairs in Local Storage.
there are already some great answers here, but note that if you decide to use a content script in your extension, that content script won't have access to localStorage. therefore chrome.storage is a good alternative.