Questions tagged [chrome-declarativenetrequest]

chrome.declarativeNetRequest API for Chrome browser extensions

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

48 questions
0
votes
0 answers

Chrome extension not changing headers is http but works in https (manifest v3)

i am working on a chrome extension that changes headers (adds custom Accept-Language header) and connects to pre-specified proxies. I was testing my product and found out that when i add some custom headers, they are only sent/changed if i use http.…
0
votes
1 answer

Why does a rule added and immediately removed with declarativeNetRequest.updateDynamicRules not get removed even after the extension is reloaded?

I am trying to write an extension in Manifest Version 3, where I want to modify cookie headers for certain requests. Since the rule will only be applied to specific requests that meets my conditions, I thought of adding a dynamic rule temporarily…
0
votes
2 answers

Chrome extension declarativeNetRequest: get notified on request blocked

The new manifest version 3 of Chrome extension API offers a new function setExtensionActionOptions which allows a typical content blocker to display the number of blocked HTTP requests for a particular tab. The question is: when to call this API?…
0
votes
0 answers

Is it possible to update parts/directives in the "content-security-policy" header using DeclarativeNetRequest API?

I am in the process of migrating from Manifest V2 to V3, from Web Request API to Declarative Net Request API. Using Web Request, I modify the "content-security-policy" header by adding a domain into the list of various directives (default-src,…
0
votes
1 answer

declarativeNetRequest Regex rules for redirecting YT shorts work when the url is typed out or opened in a new tab but not when clicked from YT itself

I'm making a Chrome extension from redirecting youtube.com/shorts/... to youtube.com/watch?v=... Everything works fine when I open those shorts links in new tabs or when I type them out but when I click from the homepage itself, they don't get…
0
votes
0 answers

Chrome Mv3 How to Inspect HTTPS headers with declarativeNetRequest

I am trying to explore on inspecting request headers using declarativeNetRequest in chrome MV3, is there any sample or documentation to achieve this.(we need to just inspect the headers for logging purpose not block or modify etc).
0
votes
0 answers

How to modify cookie names without the blocking version of WebRequest (using Manifest V3)

I developed a Chrome extension that allows me to edit cookie names before each request and after each response in order to manage different sessions on different Chrome tabs (basically, something akin to Firefox containers). I want to start porting…
0
votes
0 answers

Using declarativeNetRequest on Proxy

Scenario: Browser -> proxyurl.com -> target.com Is it possible to modify the headers sent to the proxy? It appears that the urlFilter refers to the target.com. const removeRuleIds = [1]; const addRules = [ { id: 1, priority: 1, action:…
erosman
  • 7,094
  • 7
  • 27
  • 46
0
votes
0 answers

Can declarativeNetRequest update rules before a request is sent?

I'm trying to write a Chrome extension that automatically updates the search query section of the URL for search engine requests. I would like my extension to read search engine requests using onBeforeRequest and create a new URL with my updates.…
0
votes
0 answers

Chrome extension declarativeNetRequest getDynamicRules how to export the rules?

I am using the getDynamicRules method for my chrome extension to see what rules are currently applied, I can get the rules to show in the method like below: chrome.declarativeNetRequest.getDynamicRules(rules => { console.log(rules); }) but I…
0
votes
1 answer

How to get Requested API Response Body in chrome extension manifest version 3

I am working on manifest version 3 and stuck in an endless loophole for getting the response body by requested API in the chrome extension. Goal is to have all requested API response here's the code. manifest.json { "name": "Chapter 28 (MV3)", …
0
votes
0 answers

chrome extension - TypeError: Error in invocation of declarativeNetRequest.updateDynamicRules

I'm trying to remove a single rule from dynamic rules of declarativeNetRequest of chrome with this code: const unblockHost = (clickData) => { chrome.declarativeNetRequest.updateDynamicRules({ removeRuleIds: bannedHosts.map( (h, i) => { …
0
votes
0 answers

chrome declarativeNetRequest added dynamic rules not working

I have this code in my chrome extension backround.js file const bannedHosts = []; const setupContextMenus = () => { chrome.contextMenus.create({ id: 'blockHost', type: 'normal', contexts: ['all'], title: 'Block…
0
votes
0 answers

How to add tabId to header with modifyHeader rule in manifest v3?

With webRequest in was quite easy to do: chrome.webRequest.onBeforeSendHeaders.addListener(this.addTabIdToHeader({ tabId }), { urls: ['http://*/*'] }, ['blocking', 'requestHeaders']); Now in declarativeNetRequest there is no current tab id …
0
votes
1 answer

declarativeNetRequest not working except doc requests

I am creating dynamic rules for declarativeNetRequest and passing the below data in updateDynamicRules api, I saw that these rules are only getting applied on doc type of request (refer image) and not on other requests, whereas this should work on…