3

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.

IvanRF
  • 7,115
  • 5
  • 47
  • 71

1 Answers1

4

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").

where chrome extension issues/feature requests should be sent?

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.

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • I already use a content script. I had to use `webNavigation` in order to support AJAX calls. That is, listen to changes in the URL made with AJAX. Do you know any other way? Thanks! – IvanRF Jun 06 '16 at 23:15
  • @IvanRF Then you're using onHistoryStateUpdated, not onCompleted, right? You could inject a script in the page to intercept history.pushState/replaceState (or poll the URL with timers, or monitor the DOM if there is a correlation between the URL change and a DOM modification). Is the domain YouTube? If so then there are some events that you can use to detect navigations (see https://stackoverflow.com/a/34100952). – Rob W Jun 07 '16 at 07:34
  • I'm using `onCompleted`,found it [here](http://stackoverflow.com/questions/11672230/chrome-extension-content-script-on-facebook). The domain is Facebook and I use the code to track how much time a session is active. I will try `tabs.onUpdated`, seen [here](http://stackoverflow.com/questions/7325701/chrome-extension-how-to-reload-re-execute-content-script-on-ajax-request) or `MutationObserver`. – IvanRF Jun 07 '16 at 16:10
  • @IvanRF That snippet that you linked is not using the `webNavigation` API, but the `webRequest` API. The `webRequest` API doesn't trigger a permission warning, but it is **not** a reliable indicator for navigations either. – Rob W Jun 07 '16 at 16:16
  • Sorry, that link was my starting point but I changed my code. I tested `tabs.onUpdated`, works but it's not enough. With `webNavigation.onCompleted` I can listen to the news feed scroll too. So, could a `MutationObserver` on the body work? – IvanRF Jun 07 '16 at 16:29
  • @IvanRF It depends on the website; give it a try and come back if you get stuck. – Rob W Jun 07 '16 at 16:31
  • 1
    Rob, thanks for your help! I updated the question. Finally, `MutationObserver` was the solution for me. – IvanRF Jun 07 '16 at 22:10