添加文件://。对Chrome扩展的许可 [英] Adding file://. permission to chrome extension

查看:297
本文介绍了添加文件://。对Chrome扩展的许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用chrome扩展为file:///启用权限。
在我的manifest.json中,我尝试过:

$ p $ permissions:[
file:/ // *

 permissions:[
file:// *
]

以及

 权限:[
*:/// C

这些都不起作用。

解决方案

 permissions:[
file:// * / *

除非从本地磁盘加载扩展名,否则文件访问默认情况下禁用。用户必须通过访问 chrome:// extensions / 手动批准此权限,并在允许访问文件URL复选框中打勾。



在您的代码中,您可以使用 chrome.extension.isAllowedFileSchemeAccess



用户友好的请求方式此访问请参阅此答案


How can I enable permissions for file:/// using chrome extensions. In my manifest.json I have tried:

"permissions": [
  "file:///*"
]

and

"permissions": [
  "file://*"
]

as well as

"permissions": [
  "*:///C"
]

None of these work.

解决方案

"permissions": [
    "file://*/*"
]

Unless the extension is loaded from your local disk, file access will be disabled by default. The user has to manually approve this permission by visiting chrome://extensions/ and put a tick at the "Allow access to file URLs" checkbox.

In your code, you can see whether file access is allowed using chrome.extension.isAllowedFileSchemeAccess.

For a user-friendly way of requesting this access, see this answer.

这篇关于添加文件://。对Chrome扩展的许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆