Use database in the Firefox web extension

微笑、不失礼 提交于 2019-12-08 12:56:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/53293160/use-database-in-the-firefox-web-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!