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

197
Vistas
Chrome Extension - Changing the ContenSetting value for JavaScript

I am still new to Chrome extension development, and I am currently playing a bit with it. I have now come across an error that I cannot explain. My guess is that some permission is missing. But according to the API specs, I have set all the necessary permissions. My test extension should change the value of chrome.contentSettings['javascript'].set. Actually, I want to disable JavaScript via this extension.

manifest.json

{
  "manifest_version": 3,
  "name": "Block JavaScript",
  "description": "BlockJavascript",
  "version": "0.0.1",
  "icons": {
    "16": "images/shield_green.png",
    "48": "images/shield_green.png",
    "128": "images/shield_green.png"
  },
  "action": {
    "default_icon": {
      "16": "images/shield_green.png",
      "24": "images/shield_green.png",
      "32": "images/shield_green.png"
    },
    "default_popup": "popup.html",
    "default_title": "Block JavaScript"
  },
  "permissions": ["tabs", "contentSettings"],
  "options_page": "options.html",
  "background": {
    "service_worker": "background.js"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "all_frames": true,
      "run_at": "document_start",
      "js": ["inject.js"]
    }
  ]
}

inject.js

chrome.contentSettings['javascript'].set({
  primaryPattern: '<all_urls>',
  setting: 'block'
});

Chrome Browser Error Log

Uncaught TypeError: Cannot read properties of undefined (reading 'javascript')

Stack Trace inject.js:1 (anonymous function)

chrome.contentSettings['javascript'].set({ //Error in this line
  primaryPattern: '<all_urls>',
  setting: 'block',
});

I hope that someone can help me and explain to me why this is happening. If you have any useful learning materials (besides the Chrome dev docs), I would be pleased if you could provide me with some. I generally find it very difficult to find learning material/videos explicitly for Chrome extension (manifest v3) development.

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