在 Firefox 网络扩展中使用数据库
Use database in the Firefox web extension
我想在我的 Firefox 网络扩展中使用一些数据库,我已经找到了 this,但它只是键值对的存储。
那么如何在 Firefox 网络扩展中使用数据库?
您可以使用 IndexedDB Web API:https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
有 sample extension that uses it, though it's using a library. It might be better to look at general Using IndexedDB 个示例。
您可能想要声明 "unlimitedStorage"
权限;在 Chrome 中,它解除了 5MB 的大小限制,而在 Firefox 上显然是 bypasses a user prompt。
请注意,IndexedDB 是基于来源的,因此您的内容脚本(从技术上讲,其来源是它们所在的页面 运行)将无法直接访问它;您将需要依靠 Messaging 让后台页面 "proxy" 访问。
我想在我的 Firefox 网络扩展中使用一些数据库,我已经找到了 this,但它只是键值对的存储。
那么如何在 Firefox 网络扩展中使用数据库?
您可以使用 IndexedDB Web API:https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
有 sample extension that uses it, though it's using a library. It might be better to look at general Using IndexedDB 个示例。
您可能想要声明 "unlimitedStorage"
权限;在 Chrome 中,它解除了 5MB 的大小限制,而在 Firefox 上显然是 bypasses a user prompt。
请注意,IndexedDB 是基于来源的,因此您的内容脚本(从技术上讲,其来源是它们所在的页面 运行)将无法直接访问它;您将需要依靠 Messaging 让后台页面 "proxy" 访问。