【问题标题】:Use database in the Firefox web extension在 Firefox Web 扩展中使用数据库
【发布时间】:2018-11-14 04:22:49
【问题描述】:

我想在我的 Firefox 网络扩展中使用一些数据库,我已经找到了this,但它只是键值对的存储。

那么如何在 Firefox 网络扩展中使用数据库呢?

【问题讨论】:

    标签: firefox firefox-addon-webextensions


    【解决方案1】:

    您可以使用 IndexedDB Web API:https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API

    有一个sample extension 使用它,尽管它使用的是一个库。查看一般的Using IndexedDB 示例可能会更好。

    你可能想要声明"unlimitedStorage" 权限;在 Chrome 中,它取消了 5MB 的大小限制,而在 Firefox 中,它显然是 bypasses a user prompt

    请注意,IndexedDB 是 per-origin,因此您的内容脚本(从技术上讲,其来源是它们正在运行的页面)将无法直接访问它;您需要依靠 Messaging 让后台页面“代理”访问。

    【讨论】:

      猜你喜欢
      • 2022-12-18
      • 2011-03-10
      • 2021-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 2017-06-29
      相关资源
      最近更新 更多