Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议允许访问文件网址 #2

Open
CHENJIAMIAN opened this issue Mar 29, 2023 · 2 comments
Open

建议允许访问文件网址 #2

CHENJIAMIAN opened this issue Mar 29, 2023 · 2 comments

Comments

@CHENJIAMIAN
Copy link

建议允许访问文件网址, 打开file:///D:/Desktop/*.html,扩展用不了

@qishibo
Copy link
Owner

qishibo commented Mar 29, 2023

那可能需要提权了,可以试试

@CHENJIAMIAN
Copy link
Author

Chrome扩展开发通过权限控制来限制扩展程序的行为。如果扩展需要访问文件网址,用户需要授予相应的权限。

在Chrome扩展程序的清单文件(manifest.json)中,需要添加以下权限:

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

这个权限允许扩展程序访问所有以file://开头的URL。

需要注意的是,如果扩展程序想要直接读取文件内容,还需要在清单文件中指定相应的文件。

例如,如果想要读取myFile.txt文件,需要在清单文件中添加以下内容:

"web_accessible_resources": [
"myFile.txt"
]

这个权限允许扩展程序直接访问myFile.txt文件的内容。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants