3

Is it possible to monitor network traffic with a google chrome plugin for the local page? For example, I want to monitor every time a web page requests a specific file (based on regex match), and if a user clicks the plugin, it opens a new tab to that file.

james.garriss
  • 12,959
  • 7
  • 83
  • 96
wuntee
  • 12,170
  • 26
  • 77
  • 106
  • Local meaning `file://`? – serg Jul 13 '11 at 21:51
  • no, for example, i can see in the developer tab, a page loads http://somesite.com/somemp3.mp3, and any time that happens, i want to be able to download that mp3 by clicking the button, which opens a new tab, pointing to that link... – wuntee Jul 13 '11 at 23:30
  • Also see http://stackoverflow.com/q/7819463/632951 and http://stackoverflow.com/q/6831916/632951 – Pacerier Jun 21 '15 at 21:58

1 Answers1

4

The "proper" way would be to use webRequest API, but it is still experimental:

//background.html
chrome.experimental.webRequest.onCompleted.addListener(function(details) {
    console.log("resource", details.url);
});

Meanwhile you can catch resources that are loading with the following code:

document.addEventListener("beforeload", function(event) {
    console.log("resource", event.url);
}, true);

This needs to go into a content script that runs with "run_at": "document_start".

serg
  • 109,619
  • 77
  • 317
  • 330
  • it looks like that is working, and able to find the base requests, but it seems like these files are being pulled via a GET in an SWF... any way of getting around that? – wuntee Jul 14 '11 at 01:11
  • @wuntee `beforeload` is the only method that I know, all other involve experimental api (and I am not sure if even that would work with flash). – serg Jul 14 '11 at 01:32
  • hmm... thanks for the help. its frustrating because i can see in the 'Network' tab of the developer pane, them being transmitted... assuming that pane has more privileges than an extension. – wuntee Jul 14 '11 at 03:09
  • 1
    @wuntee If you see it then experimental api should be able to catch it, in theory. There is no stable api that can access resources panel. – serg Jul 14 '11 at 05:09
  • @serg, Is it still experimental? – Pacerier Jun 21 '15 at 21:55