Search e01
One query across the encyclopedia, books, dictionary, papers, Wikidata and the developer library. Every hit carries its source.
6 results across 6 corpora for webRequest.onBeforeRequest.
Developer library 6
Intercept HTTP requests
, create a file called "background.js" and add: ```js function logURL(requestDetails) { console.log(`Loading: ${requestDetails.url}`); } browser.webRequest.onBeforeRequest.addListener(logURL, { urls: ["<all_urls>"], }); ``` You use onBeforeRequest to call the `logURL()` function just before starting the request. The `logURL()` function grabs the URL of the request from the event object and logs it to the brows
Work with documentId
k up or enumerate frame details. - **Events**: Navigation events (webNavigation.onCommitted, webNavigation.onCompleted, and others), request events (webRequest.onBeforeRequest and others), and proxy.onRequest all include `tabId` and `frameId` to identify where an event occurred. Because `frameId` identifies the frame rather than its content, there is a potential race condition. After your extension has obtained the
webRequest
t and can modify or cancel the request. Each event is fired at a particular stage of the request. The sequence of events is like this:  in your manifest.json. ## Syntax ```js-nolint browser.webRequest.onBeforeRequest.addListener( listener, // function filter, // object extraInfoSpec // optional array of strings ) browser.webRequest.onBeforeRequest.removeListener(listener) browser.webRequest.onBeforeRequest.hasListen
webRequest.filterResponseData()
uest caching. Data from this cache is not available in a form useful to extensions. If your extension needs to filter scripts, create your filter in webRequest.onBeforeRequest. Doing this ensures that the filter is created prior to the attempt to load from cache, thereby avoiding the optimized cache. ## Permissions To use this API, you must have the `"webRequest"` and `"webRequestBlocking"` [API permissions](/docs/
webRequest.StreamFilter
ent.data); }; filter.onstop = (event) => { console.log("finished"); filter.disconnect(); }; // return {}; // not needed } browser.webRequest.onBeforeRequest.addListener( listener, { urls: ["https://example.org/"], types: ["main_frame"] }, ["blocking"], ); ``` ## Browser compatibility