0

I'm trying to load a page in a tab and get the status code returned.

I'm updating the tab using

chrome.tabs.update({
  url: url
})

I have the following listener set up, but for some reason it's never being called.

chrome.webRequest.onCompleted.addListener(function processLoadPage(details) {
    console.log(`Got http status code ${details.statusCode}`);
}, { urls: ["<all_urls>"] });

I tried using chrome.tabs.onUpdated.addListener which does get called and has a status but I don't see anyway to get the actual http status code from this.

I'm using manifest v3 and this is running in a service worker. I have the following permissions

    "permissions": [
        "storage",
        "downloads",
        "tabs",
        "activeTab",
        "scripting",
        "webRequest",
        "webRequestBlocking",
        "<all_urls>"
    ],
rkb944
  • 1
  • There's a bug in Chrome: webRequest alone won't be reported to an inactive service worker, see [this topic](/a/66618269) for workarounds. – wOxxOm Apr 13 '22 at 16:26

0 Answers0