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"],
);webRequest.StreamFilter.onstart / notebook
webRequest.StreamFilter.onstart
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.