सामग्री पर जाएँ

लेसन 6 · Manifest V3 and Structure

Manifest Fields You Will Actually Use

A tour of the manifest keys beyond the basics: commands, options_ui, web_accessible_resources, minimum_chrome_version, side_panel, omnibox and more, with examples.

After the basics you will reach for a second group of keys, each one switching on a feature. This lesson is a guided reference: for each key you see what it does, a snippet and a gotcha.

content_scripts

Injects scripts into matching pages automatically.

JSON
"content_scripts": [
  {
    "matches": ["https://*.example.com/*"],
    "exclude_matches": ["https://admin.example.com/*"],
    "js": ["content.js"],
    "css": ["content.css"],
    "run_at": "document_idle",
    "all_frames": false
  }
]

run_at is document_start, document_end or document_idle (default). all_frames also injects into iframes. Gotcha: matches is required inside every entry. See match patterns and content scripts.

options_ui and options_page

JSON
"options_ui": { "page": "options.html", "open_in_tab": false }

options_ui with open_in_tab: false embeds your settings in the extensions page card, while options_page always opens a full tab. Pick one. See the options page.

commands: keyboard shortcuts

JSON
"commands": {
  "_execute_action": {
    "suggested_key": { "default": "Ctrl+Shift+Y", "mac": "Command+Shift+Y" },
    "description": "Open the popup"
  },
  "toggle-feature": {
    "suggested_key": { "default": "Alt+T" },
    "description": "Toggle the feature"
  }
}

_execute_action is a reserved name that behaves like clicking the toolbar button. Other command names fire chrome.commands.onCommand in the service worker. Users can change shortcuts at chrome://extensions/shortcuts; suggested_key is only a suggestion, and a clash with another extension means it stays unset.

web_accessible_resources

By default, web pages cannot load your extension's files. To let a page use an image, font or script that you ship, declare it:

JSON
"web_accessible_resources": [
  {
    "resources": ["images/*.png", "inject.js"],
    "matches": ["https://*.example.com/*"]
  }
]

Anything listed can be fingerprinted by the sites you match, so keep it small.

side_panel and sidePanel permission

JSON
"permissions": ["sidePanel"],
"side_panel": { "default_path": "panel.html" }

The side panel is an extension page that stays open next to the web page while the user browses.

omnibox, chrome_url_overrides and more

Key What it does
omnibox { "keyword": "tc" }: type tc + Tab in the address bar to talk to your extension
chrome_url_overrides Replace the new-tab, bookmarks or history page (one per extension)
devtools_page Add panels to Chrome DevTools
incognito "spanning" (default), "split" or "not_allowed"
minimum_chrome_version Refuse to install on older Chrome, e.g. "116"
homepage_url Link shown on the extensions page
default_locale Needed when you use _locales for translations
key Pins the extension ID during development
externally_connectable Which web pages or extensions may send messages to you
content_security_policy Tightens the extension page CSP
declarative_net_request Static rule files for request blocking

Who needs what? A planner

This stand-in takes feature names and suggests the manifest keys, then assembles a manifest for you.

JS Manifest builder (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Checking keys for typos

Misspelled keys are a classic problem: Chrome shows a warning, but the feature silently does nothing. This stand-in compares keys to a known list and suggests the closest one.

JS Find the misspelled key

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Which reserved command name acts like clicking the toolbar button?

    _execute_action triggers the action, opening the popup or firing action.onClicked.
  2. 2. Why would you add web_accessible_resources?

    Normally pages cannot reference your extension's files. This key allows it for the resources and sites you list.
  3. 3. How many chrome_url_overrides pages can one extension replace?

    An extension can override only one of the new-tab, bookmarks or history pages.

Summary

  • Features are switched on by manifest keys; match key to feature.
  • commands gives shortcuts; _execute_action equals a toolbar click.
  • web_accessible_resources exposes files to chosen pages, so list as little as possible.
  • Misspelled keys are ignored with a warning, so check the extensions page after loading.
  • minimum_chrome_version protects against APIs your users' Chrome lacks.

Next: Folder Structure, Icons and Translations

अपनी प्रगति ट्रैक करें

मुफ़्त अकाउंट बनाएँ, लेसन पूरे के रूप में चिह्नित करें और किसी भी डिवाइस पर वहीं से शुरू करें जहाँ छोड़ा था।