webRequest.StreamFilter.onstart

An event handler that will be called when when the stream is opened and is about to begin delivering data. From this point on, the extension may use filter functions like write(), disconnect(), or close().

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
Basic supportChrome No support NoEdge No support NoFirefox Full support 57Opera No support NoFirefox Android Full support 57

Legend

Full support  
Full support
No support  
No support

Examples

This example will replace the page content with "replacement text":

function listener(details) {
  let filter = browser.webRequest.filterResponseData(details.requestId);

  filter.onstart = event => {
    console.log("started");
    let encoder = new TextEncoder();
    filter.write(encoder.encode("replacement content"));
    filter.close();
  }
}

browser.webRequest.onBeforeRequest.addListener(
  listener,
  {urls: ["https://example.org/"], types: ["main_frame"]},
  ["blocking"]
);

Document Tags and Contributors

Contributors to this page: wbamberg
Last updated by: wbamberg,