Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

295
Visualizações
How to load cdn scripts in chrome extension (manifest v3) by avoiding Content Security Policy?

I have been trying to make a chrome extension which uses CDN link of Sheet.js to analyse some excel data. But getting some error related to 'Content Security Policy'.

Although I have set 'script-src-elem' explicitly in my manifest.json, but still getting following error -

Analyser.js:14 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Analyser.js:19 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

I have also tried to make a local of this scripts and loaded them using "web_accessible_resource", that time the scripts got added to the head without any above errors. But later I found that those scripts were not even working.

Manifest.jsom

{
    "name": "Extension",
    "description": "Trying to Learn",
    "version": "1.0",
    "manifest_version": 3,
    "permissions": [
        "storage",
        "activeTab",
        "scripting"
    ],
    "content_scripts": [
        {
            "matches": [
                "http://www.example.com/*"
            ],
            "js": [
                "Analyser.js"
            ]
        }
    ],
    "content_security_policy": {
        "extension_pages": "script-src-elem 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; script-src 'self';  object-src 'self'"
    }
}

Analyser.js

let cdnxlsx_1 = document.createElement('script');
cdnxlsx_1.src = 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js';
cdnxlsx_1.type = 'text/javascript';
document.head.appendChild(cdnxlsx_1);

let cdnxlsx_2 = document.createElement('script');
cdnxlsx_2.src = 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js';
cdnxlsx_2.type = 'text/javascript';
document.head.appendChild(cdnxlsx_2);
.
.
.
.
.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda