i am working on a chrome extension that changes headers (adds custom Accept-Language header) and connects to pre-specified proxies. I was testing my product and found out that when i add some custom headers, they are only sent/changed if i use http. I created a php page that displays recieved headers.
When i visit https://mytestes.com I get this
accept-language: hu
proxy-switching-extension: true
But when using http:////mytestes.com i get this, where the custom header is not even added and the Accept-Language header is not changed (the headers match my chrome network tab)
accept-language: sk-SK,sk;q=0.9,cs;q=0.8,en-US;q=0.7,en;q=0.6
proxy-switching-extension: --> **NOT SENT**
My manifest look like this
{
"name": "HTTP headers manipulator 1.0",
"version": "1.0",
"description": "Extension allows user to add custom headers to the requests sent from the web browser",
"permissions": [
"storage",
"tabs",
"webRequest",
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"declarativeNetRequestFeedback",
"proxy"
],
"declarative_net_request": {
"rule_resources": [
{
"id": "ruleset_1",
"enabled": true,
"path": "rules.json"
}
]
},
"background": {
"service_worker": "background.js"
},
"host_permissions": [
"https://*/*"
],
"content_scripts": [
{
"matches": [
"https://*/*",
"http://*/*"
],
"js": [
"contentScript.js"
]
}
],
"manifest_version": 3
}
rules.json
[
{
"id" : 1,
"priority": 1,
"action": {
"type": "modifyHeaders",
"requestHeaders": [
{ "header": "Proxy-switching-extension", "operation": "set", "value": "true" }
]
},
"condition" : {
"urlFilter" : "|http*",
"resourceTypes" : ["script", "main_frame", "sub_frame"]
}
}
]
background.js
chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
id: 1,
priority: 1,
action: {
type: 'modifyHeaders',
requestHeaders: [
{
header: "Accept-language",
operation: 'set',
value: "hu"
},
],
},
condition: {
urlFilter: '|http*',
resourceTypes: [
'main_frame',
'sub_frame',
'script'
],
},
},
],
removeRuleIds: [1]
}, async (result) => {
console.log('created', result);
});
I tried changing the condition values, but without any luck, could you please help me with this ? I need to use http for http proxies and am unable to change headers in http currenlty :( Thank you :)