Does safari support modification of request headers by using declarativeNetRequest?
I want to change the sec-fetch-dest, sec-fetch-mode value in request header using declarativeNetRequest.
So I just set the manifest value as follows.
{
"manifest_version": 3,
...
"name": "modifyHeader test",
"description": "sample extension",
"version": "1.0",
...
"permissions": [
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"activeTab"
],
"declarative_net_request": {
"rule_resources": [
{
"id": "ruleset_for_test",
"enabled": true,
"path": "test_rules.json"
}
]
},
"host_permissions": [
"<all_urls>"
],
....
"content_scripts": [{
"js": [ "content.js" ],
"matches": [ "*://www.acmicpc.net/*" ]
}],
....
}
And test_rules.json is as follows
{
"id": 1,
"priority": 1,
"action": { "type": "modifyHeaders",
"requestHeaders": [
{ "header": "sec-fetch-dest", "operation": "set", "value": "document" },
{ "header": "sec-fetch-mode", "operation": "set", "value": "navigate" }
]
},
"condition": { "domains":["acmicpc.net"], "resourceTypes": ["xmlhttprequest"] }
}
However, safari does not change the request header.
So I just wonder does safari allow modification of headers through declarativeNetRequest.
Post
Replies
Boosts
Views
Activity
Is declarativeNetRequest with action type modifyHeaders supported in safari web extension?
To modify request headers with declarativeNetRequest, I just modify the manifest.json as below.
{
"manifest_version": 3,
....
"permissions": [
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"activeTab"
],
"declarative_net_request": {
"rule_resources": [
{
"id": "ruleset_for_extension",
"enabled": true,
"path": "rules.json"
}
]
},
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js"
},
"content_scripts": [{
"js": [ "content.js" ],
"matches": [ "*://www.acmicpc.net/*" ]
}],
....
}
And rules.json is as follows
{
"id": 1,
"priority": 1,
"action": { "type": "modifyHeaders",
"requestHeaders": [
{ "header": "sec-fetch-dest", "operation": "set", "value": "document" },
{ "header": "sec-fetch-mode", "operation": "set", "value": "navigate" }
]
},
"condition": { "domains":["acmicpc.net"], "resourceTypes":["xmlhttprequest"] }
}
It builds successfully but not modify headers with as intended even though the permission in safari is enabled.