Hi, I’m trying to build a simple extension to intercept HTTP requests. My Firefox version is 140.7.0 ESR.
I follow this article: Intercept HTTP requests - Mozilla | MDN
Basically, I’ve copy-pasted the content of manifest.json and background.js files from the above article. Then I loaded the extension in the about:debugging page. The extension should print URLs into the console but when I click links on pages nothing happens.
Here’s manifest.json:
{
"description": "Demonstrating webRequests",
"manifest_version": 2,
"name": "webRequest-demo",
"version": "1.0",
"permissions": ["webRequest", "<all_urls>"],
"background": {
"scripts": ["background.js"]
}
}
And background.js:
function logURL(requestDetails) {
console.log(`Loading: ${requestDetails.url}`);
}
browser.webRequest.onBeforeRequest.addListener(logURL, {
urls: ["<all_urls>"],
});
I’m not sure what is going wrong as this is my first attempt to write an extension.
