0

I'm looking to identify the network calls made by a page with a chrome extension. These calls may include XHR requests, iframe document loads etc..

I've seen the following SO questions; however they are not helpful in this case.

Can a Chrome extension monitor XHR events (or other events) from the page it's running against?

Chrome extension: identify web requests of background-page iframe?

I've tried the webRequest api and it doesn't seem to be doing what I was expecting as well. To summarize:

If I'm loading page A; and page A makes an async request to url B, and loads an iframe from url C, I want to be able to retrieve B and C. I already have page A tracked with DomContentLoaded event.

  • I can use the DomSubTreeChanged but it's not really what I'm looking for, the calls might not alter the UI.
Community
  • 1
  • 1
Mavi Domates
  • 4,262
  • 2
  • 26
  • 45
  • _"I've tried the webRequest api and it doesn't seem to be doing what I was expecting as well."_ I'm afraid you'll need to expand on that. – Xan Jul 25 '16 at 13:57
  • Have you tried Chrome extension HTTP-Headers? –  Jul 25 '16 at 14:00
  • It sounds like you're trying to use the webRequest API to read the response body? If that's correct, then this isn't currently possible - https://bugs.chromium.org/p/chromium/issues/detail?id=104058. You'd have to use a content script or chrome.tabs.executeScript to get the page content. Also, can you share the code you currently have and why it's not working as expected? – dan Jul 25 '16 at 15:50

1 Answers1

0

Adding the listener below to background.js solved this problem.

chrome.webRequest.onBeforeRequest.addListener(
        onRequestReceived,
        {urls: ["http://*/*", "https://*/*"]},
        ["blocking"]);
Mavi Domates
  • 4,262
  • 2
  • 26
  • 45