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

195
Views
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
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!