filter.onstart = (event) => {
console.log("started");
};webRequest.StreamFilter / notebook
webRequest.StreamFilter
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
function listener(details) {
let filter = browser.webRequest.filterResponseData(details.requestId);
filter.onstart = (event) => {
console.log("started");
};
filter.ondata = (event) => {
console.log(event.data);
filter.write(event.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"],
);