Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
chrome.webRequest.onHeadersReceived cannot change headers

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"]);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!