Reputation: 2879
I want to use some database in my Firefox web extension, I already found this, but it's just a storage for key-value pairs.
So how can I use database in the Firefox web extension?
Upvotes: 3
Views: 1309
Reputation: 77531
You can use the IndexedDB Web API: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
There's a sample extension that uses it, though it's using a library. It might be better to look at general Using IndexedDB examples.
You probably want to declare "unlimitedStorage"
permission; in Chrome, it lifts the 5MB restriction on size, while on Firefox it apparently bypasses a user prompt.
Note that IndexedDB is per-origin, so your content scripts (whose origin is technically the page they are running in) won't be able to access it directly; you'll need to rely on Messaging to let the background page "proxy" the access.
Upvotes: 6