添加文件://.chrome 扩展权限 [英] Adding file://. permission to chrome extension

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

问题描述

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

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

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

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

以及

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

这些都不行.

推荐答案

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

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

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.

在您的代码中,您可以使用 查看是否允许文件访问chrome.extension.isAllowedFileSchemeAccess.

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天全站免登陆