Skip to content

Problems (i met) in Chrome Extension use #112

@ieful

Description

@ieful

I'm using chrome-har in my Chrome Extension, all i want is to record a pice of network activity and generate a HAR file.

chrome.debugger.sendCommand({ tabId }, 'Network.enable', {}); chrome.debugger.sendCommand({tabId}, 'Page.enable', {});
As above, i enabled "Network" and "Page" event debugger whitch i investigated they are Required to get HAR data

Then

chrome.debugger.onEvent.addListener(debuggerEventListener);

i add an Listener to Listen the events on the page

and then

const debuggerEventListener = (debuggeeId, method, params) => { if (recording && debuggeeId.tabId === tabId) { if (method !== 'Network.responseReceived') { networkEvents.push({method, params}); } else { const requestId = params.requestId; if (params.response) { chrome.debugger.sendCommand({ tabId: tabId }, "Network.getResponseBody", { requestId: requestId }, function (responseBody) { if (responseBody) { if (responseBody.body) { params.response.body = responseBody.body; networkEvents.push({method, params}); } else { networkEvents.push({method, params}); } } else { console.error('Error fetching response body:', error); networkEvents.push({method, params}); } }); } else { networkEvents.push({method, params}); } } } }

I collect all the event in a Array and i past the Array to harFromMessages Fun

const har = harFromMessages(eventsArrayData, {includeTextFromResponseBody: true, includeResourcesFromDiskCache: true});

The problem is i got pages: [] and entries: [] in the last har result. why???

i printed the eventsArrayData in my console, there is Obviously so many events data collected, but harFromMessages Fun gives me two [] in the result. is seems that harFromMessages dose not push my given event, I'm very confused about this

Looking forward to your answer 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions