W3cubDocs

/Web Extensions

devtools.network.getHAR()

Get a HAR log for the page loaded in the current tab.

This is an asynchronous function that returns a Promise.

Syntax

var getting = browser.devtools.network.getHAR()

Parameters

None.

Return value

A Promise that will be fulfilled with a object containing the HAR log for the current tab. For details of what the log object contains, refer to the HAR specification.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
getHAR
Yes
79
60
The returned HAR log will be empty unless the user has previously activated the browser's network panel at least once.
?
Yes
No
?
?
No
?
?
?

Examples

Log the URLs of requests contained in the HAR log:

async function logRequests() {
  let harLog = await browser.devtools.network.getHAR();
  console.log(`HAR version: ${harLog.version}`);
  for (let entry of harLog.entries) {
    console.log(entry.request.url);
  }
}

logRequestsButton.addEventListener("click", logRequests);

Note: This API is based on Chromium's chrome.devtools.network API.

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools/network/getHAR