I'm attempting to make a Chrome Extension, using Manifest Version 3, which accesses network requests originating from the webpage.
These are the relevant parts of the manifest, including permissions:
{
"manifest_version": 3,
...
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
],
"content_scripts": [
{
"js": ["scripts/content.js"],
"css": ["styles.css"],
"matches": [
"<the site>"
],
"run_at": "document_idle"
}
],
}
Inside the content script, content.js, I registered a listener to chrome.webRequest
:
chrome.webRequest.onBeforeRequest.addListener(
(request) => {
console.log(request);
}
)
When I check the page console, other log lines from from content.js show up, but no web requests.
Furthermore, when I view the script inside the Chrome Developer Tools > Sources window, I see the following error.
Edit: This question was closed prematurely, because it is supposedly a duplicate. The related questions are based on V2 of the manifest, and this question is specifically about V3. The previous answers reference background scripts, which do not exist in V3.