I'm developing a Google Chrome extension and I'd like to set up a specific user agent to a tab/page, or to a popup (iframe shown as a "bubble popup"), without affecting other pages or tabs.
Is it possible?
I'm developing a Google Chrome extension and I'd like to set up a specific user agent to a tab/page, or to a popup (iframe shown as a "bubble popup"), without affecting other pages or tabs.
Is it possible?
The
webRequest
API can be used to modify the User Agent header.Note: The Network tab at the Developer tools show the old headers. I've verified that the headers are set correctly, using netcat (
nc -l 127.0.0.1 -p 6789
).In the example below, the code activates on all tabs. Adjust the request filter to meet your requirements. Add
tabId
to limit the functionality to this filter, with the tabId of your tabs (obtainable through various APIs,chrome.tabs
in particular).background.js
manifest.json
Documentation
chrome.webRequest.onbeforeSendHeaders
event