Questions tagged [chrome-declarativenetrequest]

chrome.declarativeNetRequest API for Chrome browser extensions

Documentation: https://developer.chrome.com/extensions/declarativeNetRequest/

48 questions
3
votes
1 answer

Modifying content-security-policy response headers using declarativeNetRequest and Manifest V3

I am trying to upgrade a Chrome extension to Manifest V3. Our current application makes use of webRequest and webRequestBlocking to modify the content-security-policy directives in order to inject resources from another application into a…
2
votes
0 answers

declarativeNetRequest (declarative_net_request) does not work on cached requests served by Service Worker

Consider the following example that simply add a header to all responses from example.com and www.google.com/maps. example.com is used to show that the code is correct and works well, and for the Google Maps page, a cached version is served that…
2
votes
1 answer

modify user-agent with decarativeNetRequest and refresh page with chrome extension

Am trying to migrate a toggle to manifest V3, this toggles between web and mobile view. With new declarativeNetRequest am able to modify the header, but it does not reload page. Ideally after applying new mobile user agent, It supposed to reload and…
2
votes
0 answers

Update chrome.webRequest header modification from V2 to V3

I'm trying to update my chrome extension from V2 to V3. The part that doesn't seem to work right now is where I modify incoming headers V2: function modifyHeadersForUrls(urls: string[]) { …
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
1
vote
0 answers

How can I use dynamic rulesets to redirect and modify the headers of the same request using Chrome's declarativeNetRequest APIs?

I have been working on a Chrome extension for shared internal use to facilitate local development; as such, I need to achieve two separate things on the same request: Redirect an XHR from a public domain (specified by the user) to another domain…
1
vote
0 answers

Why modifyHeaders with declarativeNetRequest only works within iframe?

I am writing a Chrome extension that modifies the user-agent header using declarativeNetRequest API. Interesting enough, the user-agent is only modified for requests within iframes as shown in the devtools. I must have missed/misunderstood…
1
vote
0 answers

Can one intercept JSON response using declarativeNetRequest in a Chrome Extension?

I want to read the JSON returned by some XHR requests on a particular website. Is this possible with the new manifest version 3 for Chrome Extensions? In that case, how does one accomplish it with declarativeNetRequest or similar?
dani
  • 4,880
  • 8
  • 55
  • 95
1
vote
0 answers

Using chrome.declarativeNetRequest to update the First Document (HTML) Fetch request call

We have an array of tab ids stored in chrome storage, using those I wanted to modify the user-agent of the First Document Fetch call on a webPage of those tabs. i am using chrome.declarativeNetRequest API to dynamically update the rules with new Tab…
1
vote
1 answer

Intercept and replace images in web app with Chrome extension

I am attempting to write a chrome extension (for personal use) to swap/replace images loaded by a webpage with alternate images. I'd had this working for some time using chrome.webRequest, but am attempting to bring it up-to-speed with manifest…
1
vote
0 answers

Session rule to match all requests coming from iframes

I had an extension which was using the parentFrameId property on onHeadersReceived with the webRequestBlocking permission to strip specific headers for all the requests coming from the iframes of a tab. To achieve this, the condition was:…
1
vote
1 answer

Get original URL when redirecting via declarativeNetRequest + extensionPath

I need to get the url of a chrome tab when it's navigated but before the user is redirected from a rule that is set using declarativeNetRequest. At the moment the user can add a rule using context menu, it will be redirected to an internal extension…
1
vote
1 answer

How to preserve query params when use chrome.declarativeNetRequest in Chrome extension manifestv3

The declarativeNetRequest rule I set [ { "action": { "redirect": { "url": "https://another.com/api_2/luckyDog" }, "type": "redirect" }, "condition": { "requestMethods": ["get"], "urlFilter":…
1
vote
0 answers

declarativeNetRequest rule ignored for mixed-content requests

I'm trying to avoid blocking mixed-content by upgrading requests scheme to https using the declarativeNetRequest API. With the following basic rule: { condition: { excludedResourceTypes:['ping'] }, action: { …
1
vote
0 answers

Get request payload (not response body) using declarativeNetRequest (for Chrome Extension)

I'm building an extension (MV3) that will make demoing data in apps easier (ie. pumping fake data into a chart to make it more realistic than typical fake demo data). My current approach is to take a user-inputted endpoint (ie.…
1
vote
0 answers

Response headers update with declarativeNetRequest update rules not visible in Chrome's DevTools

In my chrome extension V3 I use chrome.declarativeNetRequest.updateSessionRules to modify response headers: chrome.declarativeNetRequest.updateSessionRules({ addRules: [ { id: 999, priority: 1, condition: { …
1
2 3 4