How to request all host permission in a non-ui declarativeNetRequest MV3 extension?

I have a Chrome extension that modifies the response header for every csv file, so that it’s always opened in the browser instead of downloading it.
It only consist of the manifest.json and the declarativeNetRequest rule set with the condition and the required modifyHeaders operations.
How am I supposed to request the all host permission as the extension has no ui at all?

2 Likes

You can use an onboarding page.

Thank you.
I implemented an onboarding page with a button for user interaction.
This is the manifest part

"permissions": [
"declarativeNetRequestWithHostAccess",
"declarativeNetRequestFeedback"
 ],
"host_permissions": ["*://*/*"],

How do I request this with browser.permissions.request?

Permissions_Onboarding_Page.zip (5.4 KB)

  1. Unzip the attachment, and install it as a temporary extension
  2. The onboarding page opens automatically
  3. Click the button
  4. Grant the *://*/* host permission

Hi Hans,
thank you very much!
I thought I have to set permissions and origins in the permissions object.
Requesting the origins only didn’t came into my mind.