Reputation: 6330
The documentation says "An instance of the extension's DevTools page is created each time a DevTools window opens. The DevTools page exists for the lifetime of the DevTools window."
However, the Facebook Pixel Helper manages to to get network information without the devtools window being open.
So, I was wondering if there was some other API or a workaround to access the content from the DevTools window (specifically the networks tab, which Facebook seems to be able to do).
Upvotes: 4
Views: 8458
Reputation: 349012
The chrome.devtools
API cannot be used without opening the devtools window. The Facebook Pixel Helper uses the chrome.webRequest
API to get information about network requests. This API does not offer any access to the response body, so that's not particularly helpful.
There are some more (powerful) methods, which are not used by the FB Pixel Helper extension:
The chrome.debugger
API allows you to do almost anything that the devtools is capable of, including querying the response body, as long as the devtools window is not open. In the following explanation, I assume that you're already attached to the debugger. If you don't know how to do that, see this answer for an example.
chrome.debugger.onEvent
Network.enable
command to start listening to events.onEvent
event will be triggered, with the method name set to Network.responseReceived
. The event parameters include things like the request/response headers, status line, etc. If you want to get the response body as well, invoke the Network.getResponseBody
command to get the response body. For other network events/commands, see the debugging protocol specification for network.
performance.timing
API to query load times of the document in a (top-level/sub) frame.Upvotes: 8