4

I need to get a frame's HTTP headers programmatically from Javascript. It doesn't need to be portable (I only need it for Chrome) and I don't mind having to add/write a specific extension.

Or, even better and more importantly, I need to have access to all network traffic from and to a specific site programmatically as it happens.

Is there a way to do this? Do I need to write my own extension to make it happen? And if so, can I write the extension in Javascript?

Writing an extension seems to be the only way to go. I could write one and use the chrome.* API like here: https://developer.chrome.com/extensions/devtools_network If writing an extension is the way to go, how would you go about it?

Sam
  • 7,252
  • 16
  • 46
  • 65
Merc
  • 16,277
  • 18
  • 79
  • 122

1 Answers1

7

The chrome.network.devtools API can only be used in a devtools extension, which is only active when the devtools for a page has been opened.

With the chrome.webRequest extension API, you can access the following information:

Requests can be filtered by URLs, request types and per tab/window.

These APIs are only available to extensions, so you have to develop a Chrome extension. Read the Getting started tutorial to get started.

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • Only one quick question: is there a way to run a custom non-extension function when a response is received? Basically, is there a way for me to define, in my *non-extension* code, a function that will get called by my custom extension (passing the response headers as parameters) whenever a response is received? – Merc Apr 13 '14 at 22:35
  • Actually, I realise this is a brand new question... here! http://stackoverflow.com/questions/23049669/how-do-i-provide-an-extra-function-to-javascript-code-through-an-extension – Merc Apr 13 '14 at 23:20