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

196
Visualizações
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 à 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