Use the chrome.experimental.devtools.network
module to retrieve
the information about network requests displayed by the Developer Tools
in the Network panel.
See DevTools APIs summary for general introduction to using Developer Tools APIs.
Network requests information is represented in the HTTP Archive format (HAR). The description of HAR is outside of scope of this document, please refer to HAR v1.2 Specification.
In terms of HAR, the
chrome.experimental.devtools.network.getHAR()
method returns
entire HAR log, while
chrome.experimental.devtools.network.onRequestFinished
event
provides HAR entry as an argument to the event callback.
Note that request content is not provided as part of HAR for efficieny
reasons. You may call request's getContent()
method to retrieve
content.
If the Developer Tools window is opened after the page is loaded,
some requests may be missing
in the array of entries returned by getHAR()
.
Reload the page to get all requests.
In general, the list of
requests returned by getHAR()
should match that displayed in
the Network panel.
The following code logs URLs of all images larger than 40KB as they are loaded:
chrome.experimental.devtools.network.onRequestFinished.addListener( function(request) { if (request.response.bodySize > 40*1024) chrome.experimental.devtools.console.addMessage( chrome.experimental.devtools.console.Severity.Warning, "Large image: " + request.request.url); });
You can find more examples that use this API in Samples.