javascriptgoogle-chrome-extensionchrome-declarativenetrequest

setting User-Agent with declarative net request is not working


I am trying to modify User-Agent with declarative net API and I have all the needed permission set and no error is showing but the user agent is still not changing.

> manifest.json

    "permissions": [
    "declarativeNetRequestWithHostAccess",
    "declarativeNetRequestFeedback"
],
  "host_permissions": [
    "<all_urls>"
]

> rule

[
    {
        "id": 1,
        "priority": 1,
        "action": {"type": "modifyHeaders",
        "requestHeaders": [{"header": "User-Agent", "operation": "set", "value": "success"}]},
        "condition": {
            "urlFilter": "http*"
        }
    }
]

Solution

  • Adding resourceTypes: [ "main_frame" ] in condition as stated in Chrome Extension Manifest Version 3 custom user agent is not getting set somehow fix the problem. I don't know how but it works I would like to hear a detail explanation. What is main frame resource type?.