declarative_net_request - request header logging

45 views
Skip to first unread message

Ilgaz KILIÇGEDİK

unread,
Jan 31, 2023, 3:12:18 PM1/31/23
to Chromium Extensions
Hi folks,

I am looking a way to get a specific header's value (let's say the header name is "token") from a web page. I'll use this value in my extension to make my extension's requests valid.

When the web page is loading, it makes a xmlHttpRequests and I can get this header value by devtool.js. But user must open devtools window and refresh the page to make this happen. So it s*cks.

As I searched from google, formerly it was possible to do that by "chrome.webrequest.onbeforerequest" but as I am using manifest v3, my chrome browser doesn't recognize webrequest object. 

Is there any way to accomplish this by declarative_net_request? Or by any other way...

Thanks a million!

wOxxOm

unread,
Feb 1, 2023, 11:16:17 AM2/1/23
to Chromium Extensions, ilg...@gmail.com
The correct solution is chrome.webRequest.onHeadersReceived.
It should be used in an extension script such as the background script, not a content script.
It also requires adding "webRequest" to permissions and the site's URL to host_permissions in manifest.json.

wOxxOm

unread,
Feb 1, 2023, 11:17:26 AM2/1/23
to Chromium Extensions, wOxxOm, ilg...@gmail.com
If you want to see the outgoing headers, use onSendHeaders event.
Reply all
Reply to author
Forward
0 new messages