Being able to exclude chrome-extension:// domains with chrome.declarativeNetRequest

116 views
Skip to first unread message

Justin Phu

unread,
Aug 16, 2023, 5:20:44 PM8/16/23
to Chromium Extensions
Hey,

I've been using Chrome Declarative Net Request in MV3 (https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/).

I want to be able to block all fetch requests to a certain domain except if it's being called from within the extension background service worker.

However, it seems like `excludedInitiatorDomains" does not seem to support chrome-extension://* url path. Am I just missing something here?

My ruleset looks as follows:

```
[
  {
    "id": 1,
    "priority": 1,
    "action": {
      "type": "block"
    },
    "condition": {
      "urlFilter": "||myendpoint.com",
      "excludedInitiatorDomains": [
        "chrome-extension://aeblfdkhhhdcdjpifhhbdiojplfjncoa"
      ],
      "resourceTypes": ["xmlhttprequest"]
    }
  }
]
```

Is it possible to prevent fetch calls to a certain domain but allowlisting the background extension service worker?

Kind regards,
Justin Phu

Jackie Han

unread,
Aug 17, 2023, 1:07:52 AM8/17/23
to Justin Phu, Chromium Extensions
"excludedInitiatorDomains" is a list of domains. The extension id is the domain part of an extension.
So you can try: "excludedInitiatorDomains": [ "aeblfdkhhhdcdjpifhhbdiojplfjncoa" ],

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/193bc02d-f4cc-4df8-8860-3c72c5147706n%40chromium.org.

Justin Phu

unread,
Aug 17, 2023, 12:34:38 PM8/17/23
to Jackie Han, chromium-...@chromium.org
That worked perfectly!

Thanks for the quick response and help @Jackie Han 😀

Kind regards,
Justin Phu

Sent with Shortwave
Reply all
Reply to author
Forward
0 new messages