如何去除权限警告"Read and change all your data on the websites you visit"?

How to remove the permission warning "Read and change all your data on the websites you visit"?

我创建了一个 Chrome 扩展来为我的网站提供额外的功能。

在添加我的扩展程序时,用户会播种该扩展程序能够 "Read and change all your data on the websites you visit" 的消息。

如何删除此权限?

目前我还没有最终确定网站的域名。我可以使用其他机制来识别我的站点(而不是域)吗?

由于您完全控制网站和扩展程序,您可以使用 externally_connectable to enhance your website. This manifest key allows code on your website to initiate and maintain a communication channel between the website and your extension. Then you can implement the platform-independent parts (e.g. UI with HTML & CSS) in your website, delegate the Chrome-specific parts to the extension, and use the messaging API 在页面和扩展程序之间进行通信。

用户收到的警告会不那么可怕:

Permissions:

  • Communicate with cooperating websites

如果您的扩展不需要 运行 在网站上,而只需要能够向您的网站发送 HTTP 请求(例如通过 API),那么您可以添加CORS headers 到网站以允许扩展程序提出请求。


您还可以 use optional permissions 通过内容脚本支持新站点。使用此方法,Chrome 在安装时不会显示任何警告。这种方法的一个缺点是您的用户必须批准另一个权限请求才能在您的网站上使用您的扩展程序。

域名是指定特定站点的唯一方式。如果您还不知道域,那么 optional permissions 是您最好的选择。

另请参阅 https://developer.chrome.com/extensions/permission_warnings#warnings 以了解导致警告的原因的说明。据此,它可能是由以下任何一种原因引起的:

  • "debugger"权限
  • "pageCapture"权限
  • "proxy"权限
  • "permissions" 字段中匹配所有主机的匹配模式
  • 一个 "content_scripts" 字段,其中 "matches" 条目匹配所有主机
  • "devtools_page"

通常是权限中的通配符匹配模式,例如http://*/*。如果您有浏览器操作或页面操作,那么您可以使用 Active Tab 权限来访问页面内容,而无需请求特定站点的权限。