I'm trying to change chrome headers. I've tried two approaches
1) use chrome extensions
2) Write my own extension
1) I've installed Requestly and added a rule
Now if I load, for example, facebook.com and open the dev-tools, I don't see this response header
I don't see why this doesn't work. I assume that the rule set in Requestly applies to all tabs.
2) This approach was inspired by this post. So, I created an extensions with the following code:
function updateHeaders() {
chrome.webRequest.onHeadersReceived.addListener(function(details){
for(var i = 0; i < details.responseHeaders.length; ++i)
if(details.responseHeaders[i].name.toLowerCase() == 'server')
details.responseHeaders[i].value = 'barfoo';
return {responseHeaders:details.responseHeaders};
}, {urls: ['*://*']}, ['blocking', 'responseHeaders']);
}
document.addEventListener('DOMContentLoaded', updateHeaders());
manifest.json
{
"manifest_version": 2,
"name": "Getting started example",
"description": "Replace the server header",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "Click here!"
},
"permissions": [
"webRequest"
]
}
Which doesn't work too
I must admit I have no experience with building chrome extensions, so the changes are pretty big that what I'm trying here doesn't make any sense, so any help would be appreciated!