The chrome.webRequest API can be used to observe and analyze traffic and to intercept, block, or modify requests in-flight.
Questions tagged [chrome-webrequest]
26 questions
6
votes
0 answers
Can I make a browser extension return a custom response for a web request?
In a Firefox or Chrome(1) extension (using WebExtensions), is it possible to interrupt a request and return an alternate response instead, preventing the network request? What I'd like to do is store some html data (dynamically) using the storage…

freyley
- 4,145
- 3
- 20
- 25
2
votes
1 answer
Cookies in an iframe inside an electron app stop working when setting custom header via webRequest.onBeforeSendHeaders
I have an iframe in an electron app (v6.1.2) that loads an external URL. I need to load that URL with a custom header, therefore I use webRequest.onBeforeSendHeaders() in order to intercept the requests and insert that header. As soon as I pass…

Constantin Groß
- 10,719
- 4
- 24
- 50
2
votes
1 answer
Chrome Extension : URL permission not working
We are using chrome webrequest API to intercept and modify headers on request.
I was working fine until Chrome 72, but it's not working anymore. But when I replacing the permission with "" that's work.
Also, I tried with another domain,…

Xeewi
- 39
- 1
- 7
2
votes
1 answer
Chrome extension not loading properly after adding redirectUrl on webRequest.onBeforeRequest
I am trying to develop a chrome extension using chrome.webRequest API. My extension will redirect https://google.com to https://stackoverflow.com. Functionality wise its working fine but after adding redirectUrl in chrome webRequest API my chrome…

Ajithkumar_sekar
- 631
- 9
- 23
2
votes
1 answer
WebExtensions: browser.webRequest.onCompleted never fires
I'm using the Firefox WebExtensions API with the following background script
var log = console.log.bind(console)
log('hello world from browser extension')
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onCompleted
var…

mikemaccana
- 110,530
- 99
- 389
- 494
1
vote
0 answers
Try to develop Chrome Extension for freely changing UserAgent, but it doesn't work well
I am developting chrome-extension.
I want to change UserAgent of browser with rewriting http header using chrome-webrequest API, but something is wrong...
I want this codes to behave expected, but I don't know what to do.
Can I give me…

Pirikara
- 343
- 3
- 12
1
vote
2 answers
chrome.webRequest.onBeforeRequest.addListener not blocking an array of urls
I am trying to block an array of urls based on user input. I have the url array in JSON format, but the sites are not actually being blocked when I navigate to them. If I use only one site, instead of an array, it does get blocked successfully. Here…

Joe
- 13
- 3
1
vote
2 answers
chrome.webRequest.onBeforeRequest causes some features of web pages to fail to load
I'm writing a chrome extension. I want it to block all pages on en.wikipedia.org, EXCEPT the Main_Page. I used chrome.webRequest.onBeforeRequest to do this.
Here is the code I used for the background script of my chrome…

DoomsterHedgehog
- 13
- 5
1
vote
0 answers
Using webRequest API to intercept script requests, edit them and send them back
As the title says, I'm trying to intercept script requests from the user's page, make a GET request to the script url from the background, add a bit of functionality and send it back to the user.
A few caveats:
I don't want to do this with every…

Victor
- 23
- 1
- 6
1
vote
0 answers
301 Redirected requests not intercepted by Chrome WebRequest API
I developed a Chrome Extension which manipulates response headers of network requests.
chrome.webRequest.onHeadersReceived.addListener(
manipulateResponseHeaders,
{ urls: [''] },
['blocking', 'responseHeaders']
);
function…

Vaibhav Nigam
- 1,334
- 12
- 21
1
vote
0 answers
How to change http method using chrome.webRequest API
Am using chrome.webRequest API to modify incoming requests and responses. However, I recently encountered a scenario where am required to intercept a POST call and change it to a GET call. I tried changing the method in object that I get in the…

Karthik Balasubramanian
- 1,127
- 4
- 13
- 36
1
vote
0 answers
Rx.js, handling Chrome Extension webrequest API callback functions
I'm trying to use Rx.js to handle the flow of Chrome extension webrequest API.
Each webrequest addListener() call takes a mandatory callback function as the first parameter. This sends request objects to the function. However, the callback can…

Tom
- 1,447
- 1
- 12
- 26
0
votes
0 answers
How to Rewrite the webRequest API with declarative_net_request API in Chrome Extension V3
I am trying to migrate my extension from V2 to V3. In V3 the webRequest API has been deprecated and replaced by declarative_net_request API. I want to rewrite the below code block using declarative_net_request API, but I don't have idea on how this…

Aniket
- 1
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…

rick-rtt
- 1
- 1
0
votes
1 answer
urls are not blocking while working with chrome.webRequest api
I have stored some urls in chrome.storage.sync like below......
sitesToBeBlocked: {
"https://www.google.com/":"https://www.google.com/" ,
"https://www.example.com/": "https://www.example.com/"
}
Now i am trying to block these urls using the…

Saurabh Raj
- 65
- 6