是否有任何方法可以使Chrome扩展程序使用一个或多个文本文件作为数据库?

我四处寻找蚂蚁,我发现的唯一类似的东西是-http://eligrey.com/demos/FileSaver.js/

顺便说一句。我正在使用jQuery(从网上获取信息并将其存储在个人计算机上的文件中)

最佳答案

对于Chrome扩展程序,您可以使用chome.storage API。

免责声明:正如我在评论中所说,Chrome扩展程序文档警告:


  不应存储机密用户信息!存储区域未加密。


docs

您需要在清单中启用存储权限:

{
    "name": "My extension",
    ...
    "permissions": [
      "storage"
    ],
    ...
}


然后您可以利用:

function saveChanges() {
        // Get a value saved in a form.
        var theValue = textarea.value;
        // Check that there's some code there.
        if (!theValue) {
          message('Error: No value specified');
          return;
        }
        // Save it using the Chrome extension storage API.
        chrome.storage.sync.set({'value': theValue}, function() {
          // Notify that we saved.
          message('Settings saved');
        });
      }

关于javascript - 如何使扩展名从文件读/写,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32500132/

10-12 12:38
查看更多