Skip to main content
Watch every request a page makes with the webRequest API. In Manifest V3 the listeners are observational: you can log, measure, and analyze traffic, but not rewrite it in JavaScript.

What MV3 allows

Regular Chrome installs cannot use webRequestBlocking in Manifest V3. If your goal is to block or rewrite traffic, declare rules instead. See Build an ad blocker.

Manifest

The webRequest events only fire for hosts that your extension can access, so pair the permission with host permissions.
manifest.json

Observe requests in the background

Register listeners at the top level of the background script, so the service worker re-registers them on every wake.
background.js
Each details object carries the request id, tab id, method, URL, resource type, and timing. Correlate events by details.requestId to build a full request timeline.

Inspect requests in a devtools panel

For request inspection with response bodies, a devtools panel is the better surface. The chrome.devtools.network API exposes finished requests as HAR entries, and it needs no webRequest permission. The devtools_page registers the panel:
devtools/scripts.js
The panel then records traffic for the inspected tab:
panel/scripts.js
The listener only receives traffic while devtools is open on that tab. Use chrome.devtools.network.getHAR to read what loaded before the panel attached.

Run it

Open any page and watch the background console log traffic. Then open devtools on the page and choose the Requests panel.

Firefox differences

  • Firefox Manifest V3 still supports blocking webRequest with the webRequestBlocking permission.
  • Firefox treats Manifest V3 host permissions as opt-in. Users grant them from the extensions panel, not at install time.
  • Firefox runs the background as an event page, not a service worker. Top-level listener registration works on both.
  • The devtools APIs above work in Firefox under the same chrome.devtools.* names.
See Cross-browser compatibility for the shared API surface.

Start from a template

The devtools template ships a working devtools_page plus panel wiring.
Repository: extension-js/examples/devtools

Best practices

  • Narrow the urls filter on each listener instead of listening to <all_urls> in production.
  • Correlate events by requestId rather than by URL, since pages repeat URLs.
  • Keep listeners fast, because every observed request invokes them.
  • Request the narrowest host permissions that your feature needs.
  • Use declarativeNetRequest for blocking, and keep webRequest for observation.

Next steps