Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

292
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda