是否可以将HTML页面和本地Javascript库制作成具有数据存储功能的Chrome扩展程序?

时间:2021-06-26 17:13:44

I have been trying to author a Chrome extension recently and have been hitting major problems it seems every step of the way.

我最近一直试图创建一个Chrome扩展程序,并且在每一步都遇到了重大问题。

Currently I have a local HTML page that is using a local Javascript library. This works great, except Chrome limits the amount of data a page can store to 5MB. I would like to get around this limit, and read that Chrome extensions/applications could use unlimited storage resources via chrome.storage.

目前我有一个使用本地Javascript库的本地HTML页面。这非常有用,除了Chrome限制页面可以存储的数据量为5MB。我想绕过这个限制,并了解Chrome扩展程序/应用程序可以通过chrome.storage使用无限的存储资源。

While coding, I quickly discovered that this only applies to browser actions, content scripts, and (?) web applications (loading an WWW page as an extension). I was coding this as a local packaged app, which does NOT have access to either the HTML5 localStorage API NOR the chrome.storage API. I really need the extension to use only local HTML/Javascript resources in order to maintain offline/no-internet functionality.

编码时,我很快发现这只适用于浏览器操作,内容脚本和(?)Web应用程序(将WWW页面作为扩展加载)。我将其编码为本地打包应用程序,该应用程序无法访问HTML5 localStorage API或chrome.storage API。我真的需要扩展只使用本地HTML / Javascript资源,以维护离线/无互联网功能。

Can a Chrome web app be loaded from a local resource, i.e. a locally packaged HTML page? Is there any way around these problems that does not include enabling dangerous security vulnerabilities in Chrome? I saw that an NPAPI app could solve the problem however that also defeats the purpose of the application I am making.

可以从本地资源(即本地打包的HTML网页)加载Chrome网络应用吗?有没有解决这些问题的方法,不包括在Chrome中启用危险的安全漏洞?我看到一个NPAPI应用程序可以解决问题但是这也违背了我正在制作的应用程序的目的。

TIA, Trann

TIA,Trann

1 个解决方案

#1


0  

Apparently this is possible with a packaged app, when the correct combination of permissions are put into the manifest.json:

显然,对于打包的应用程序,当正确的权限组合放入manifest.json时,这是可能的:

"permissions": [
    "storage",
    "unlimitedStorage",
    "fileSystem"
]

The fileSystem permission, once added, enabled the FileSystem API to start working as expected (not chrome.storage).

fileSystem权限一旦添加,就会使FileSystem API按预期开始工作(而不是chrome.storage)。

#1


0  

Apparently this is possible with a packaged app, when the correct combination of permissions are put into the manifest.json:

显然,对于打包的应用程序,当正确的权限组合放入manifest.json时,这是可能的:

"permissions": [
    "storage",
    "unlimitedStorage",
    "fileSystem"
]

The fileSystem permission, once added, enabled the FileSystem API to start working as expected (not chrome.storage).

fileSystem权限一旦添加,就会使FileSystem API按预期开始工作(而不是chrome.storage)。