I'm trying to remove content-security-policy header It work on other websites but not on tiktok.com. but I can see in debugger that the headers is modified.
manifest.json
{
"manifest_version": 2,
"name": "test ex",
"short_name": "test",
"version": "1.0",
"description": "test",
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"declarativeContent",
"webRequest",
"webRequestBlocking",
"https://www.tiktok.com/*",
"tabs",
"webNavigation",
"storage"
]
}
background.js
var webReqOpts = {
urls: ["https://www.tiktok.com/*"]
};
function modifyResponseHeaders(response) {
if (response.type == "main_frame" || response.type == "sub_frame") {
var headers = response.responseHeaders,
newHeaders = [],
i;
for (i = 0; i < headers.length; ++i) {
if (!['content-security-policy', 'content-security-policy-report-only'].includes(headers[i].name.toLowerCase())) {
newHeaders.push(headers[i]);
}
}
return {
responseHeaders: newHeaders
};
}
}
chrome.webRequest.onHeadersReceived.addListener(modifyResponseHeaders, webReqOpts, ["blocking", "responseHeaders"]);