本文介绍了改进chrome.webNavigation的权限警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 chrome.webNavigation 时,需要webNavigation权限.如权限警告所述,使用该权限可使安装程序显示警告消息:

  • Read your browsing history

就我而言,我只想听一个特定的域,比方说domain.com.因此,我需要过滤chrome.webNavigation.onCompleted.addListener()的回调.

现在,从用户的角度来看,由于读取您的浏览历史记录"的范围太广,并且他们只能在domain.com上使用,因此他们可以不相信chrome扩展名.

在权限中使用匹配模式时,将使用类似Read and change your data on all domain.com sites and www.domain.com的消息.

还有其他方法可以使用chrome.webNavigation并且仅收听一个域吗? chrome扩展问题/功能请求应发送到哪里?


更新:我必须使用webNavigation才能支持AJAX调用.也就是说,监听DOM和使用AJAX进行的URL中的更改.我通过使用 MutationObserver .因此,我可以删除权限.最初的问题已经由Rob W报告为错误.

在这种情况下,我一年多前已经发布了功能请求: https://crbug.com/431108 (允许扩展程序在未经webNavigation许可的情况下使用webNavigation API").

https://crbug.com/new 上报告功能请求和错误(指向 https://bugs.chromium.org ).

如果您想获得与chrome.webNavigation.onCompleted相同的效果而无需使用webNavigation API或添加额外的权限,则可以声明内容脚本将消息发送到后台页面, window.onload事件触发.

When using chrome.webNavigation the webNavigation permission is needed. As stated on Permission Warnings, using that permission makes the installer to show the warning message:

  • Read your browsing history

In my case, I only want to listen to one specific domain, let's say domain.com. So, I need to filter the callback for chrome.webNavigation.onCompleted.addListener().

Now, from the user perspective, they could distrust the chrome extension since "Read your browsing history" is too broad and the extension should only work on domain.com.

When a match pattern is used in the permissions, a message like Read and change your data on all domain.com sites and www.domain.com is used.

Is there any other way to use chrome.webNavigation and only listen to one domain? where chrome extension issues/feature requests should be sent?


Update: I had to use webNavigation in order to support AJAX calls. That is, listen to changes in the DOM and the URL made with AJAX. I solved this particular case by using a MutationObserver. Thus, I could remove the permission. The original question was already reported as a bug by Rob W.

解决方案

In this case, I've already posted a feature request over a year ago: https://crbug.com/431108 ("Allow extensions to use webNavigation API without webNavigation permission").

Report feature requests and bugs at https://crbug.com/new (points to https://bugs.chromium.org).

If you want to get the equivalent effect of chrome.webNavigation.onCompleted without using the webNavigation API or adding extra permissions, then you can declare a content script and send a message to the background page when the window.onload event fires.

这篇关于改进chrome.webNavigation的权限警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-20 23:53