From a88ae7b514dd82554c4f2fa4b42e99415520a04c Mon Sep 17 00:00:00 2001 From: Jethro Nederhof Date: Thu, 14 Mar 2019 12:19:39 +1100 Subject: [PATCH] Handle network requests made before opening extension Should fix #24. This was actually the original behaviour but got refactored out. I don't think it's possible to run code before our DevTools panel becomes active, but it's a small change to process whatever the Network panel has already seen, and a significant quality of life improvement. Thanks @ScottyMJacobson! --- src/BeaconInspector.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/BeaconInspector.ts b/src/BeaconInspector.ts index 09e8a02..46c7a94 100644 --- a/src/BeaconInspector.ts +++ b/src/BeaconInspector.ts @@ -51,8 +51,14 @@ const BeaconInspector = () => { } return { - // @ts-ignore typedefs for chrome aren't complete for the HAR spec. - oninit: () => chrome.devtools.network.onRequestFinished.addListener(handleNewRequest), + oninit: () => { + chrome.devtools.network.getHAR((harLog) => { + (harLog as { entries: har.Entry[] }).entries.map(handleNewRequest); + + // @ts-ignore typedefs for chrome aren't complete for the HAR spec. + chrome.devtools.network.onRequestFinished.addListener(handleNewRequest); + }); + }, view: () => ([ m(Toolbar, { clearRequests: () => (requests = [], active = undefined),