The example for http-response did not work as expected
I tried to load the extension after clone the code from this link:
https://github.com/mdn/webextensions-examples/tree/master/http-response
After that I see the extension does not work, the domain example.com is not used anymore.
The I tried to change the code to something like this:
function listener(details) {
let filter = browser.webRequest.filterResponseData(details.requestId);
let decoder = new TextDecoder("utf-8");
let encoder = new TextEncoder();
filter.ondata = event => {
let str = decoder.decode(event.data, {stream: true});
// Just change any instance of Example in the HTTP response
// to WebExtension Example.
str = str.replace(/^.*$/g, 'WebExtension Example');
filter.write(encoder.encode(str));
filter.disconnect();
}
return {};
}
browser.webRequest.onBeforeRequest.addListener(
listener,
{urls: ["https://google.com/*"], types: ["main_frame"]},
["blocking"]
);
But the extension still not work as expected.
Can you please take a look the problem for me?
What do you mean with "[...] the domain example.com is not used anymore"? It is available since roughly 20 years and still can be used for demonstrating examples.
To make your version with google.com working you'll need to add google to the manifest here: https://github.com/mdn/webextensions-examples/blob/master/http-response/manifest.json#L13
I was recently working on a pull request to improve the http-response example (#460) and I can confirm that this extension was working as expected before I made any changes to it, so I don't think there is likely an issue. @bugb Have you tried it recently?
Assumed resolved as no further comment for 3 years