0

I'm trying to develop a Chrome extension to add a new response header to responses from a specific web site. My manifest.json file is as follows:

{
  "name": "MVX",
  "version": "0.0.1",
  "manifest_version": 2,
  "background": {
    "scripts": ["background.js"]  
  },
  "permissions": [ "webRequest", "webRequestBlocking", "<all_urls>" ]
}

background.js file is as follows:

chrome.webRequest.onHeadersReceived.addListener(
(x) => {
    x.responseHeaders.push({name:"Some", value: "Data"});
    return {responseHeaders: x.responseHeaders };
},
{ urls: ["https://www.website.com/*"] },
["blocking","responseHeaders"]
);

The problem is suprising. When I make a request myself to this website code does not work, but when web page makes a request itself to get a resource such as image or js file (everthing except the web page) code works. I can see this from Chrome DevTools > Network tab. How can I solve this problem?

1
  • It may be a bug in devtools i.e. the header is actually added but not shown. It may be a known bug in Chrome if you open the site from another extension that replaces the new tab. Commented Jan 29 at 3:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.