Created
January 30, 2018 11:48
-
-
Save amitmbee/4258e73d7da3a9823d2250c7feed8fa2 to your computer and use it in GitHub Desktop.
[Set response headers on Chrome extensions API]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| chrome.webRequest.onHeadersReceived.addListener(//For getting responses : use onHeadersReceived Event | |
| callback, | |
| { | |
| urls: ["<all_urls>"], | |
| types: ["xmlhttprequest"], | |
| }, | |
| ["blocking", "responseHeaders"]// For response event use ["blocking", "responseHeaders"] filters and return {responseHeaders: details.responseHeaders}; to block and modify requests | |
| ); | |
| function callback(details){ | |
| details.responseHeaders.find((headerType,index) => { | |
| console.log(headerType) | |
| if(headerType.name == 'status'){ | |
| headerType.value = '404' | |
| } | |
| if(headerType.name === "content-type"){ | |
| headerType.value = "" | |
| } | |
| if(headerType.name === "pragma"){ | |
| headerType.value = "" | |
| } | |
| if(headerType.name === "expires"){ | |
| headerType.value = "" | |
| } | |
| }) | |
| return { responseHeaders: details.responseHeaders }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment