Browser Extensions Development (Chrome & Edge) · 课时

理解 Manifest V3 结构

深入探索 manifest.json 文件,了解 Manifest V3 的必填字段和常见配置

第 1 / 4 课11 个步骤

理解 Manifest V3 结构 是 CoddyKit 上的免费 Browser Extensions Development (Chrome & Edge) 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Browser Extensions Development (Chrome & Edge) 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Browser Extensions Development (Chrome & Edge) 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

The Blueprint of Your Extension

Every browser extension starts with a core configuration file called manifest.json. Think of it as the blueprint or identity card for your extension.

This file tells the browser everything it needs to know: its name, version, what permissions it needs, and which files make up its different parts.

Introducing Manifest V3

Manifest V3 is the latest version of the extension platform, bringing significant changes focused on security, privacy, and performance.

All new extensions must use Manifest V3, and existing extensions are migrating. Understanding its structure is crucial for modern extension development.

Required Field: manifest_version

The manifest_version field is mandatory and tells the browser which set of APIs and security features your extension expects.

  • For Manifest V3, this value must always be 3.
  • It's the very first declaration in your manifest.json file.

Required Fields: name and version

These two fields are also essential for every extension:

  • name: This is the user-visible name of your extension. It appears in the browser's extension management page and in the web store.
  • version: This specifies the version of your extension, typically following semantic versioning (e.g., "1.0.0"). It helps users track updates.

Your First Manifest File

Let's see the absolute minimum needed for a valid Manifest V3 file. This simple JSON structure is the foundation for any extension you build.

{
  "manifest_version": 3,
  "name": "My Basic Extension",
  "version": "1.0"
}

Optional Field: description

While not strictly required, adding a description is highly recommended. It provides a short summary of what your extension does.

This description is visible to users in the browser's extension management page and is crucial for your listing in the Chrome Web Store or Edge Add-ons store.

Optional Field: icons

The icons field allows you to define images that represent your extension. Browsers use different sizes for various UI contexts:

  • Toolbar buttons (16x16, 24x24, 32x32 pixels)
  • Extension management page (48x48 pixels)
  • Web store listing (128x128 pixels)

Always provide a 128x128 icon for store listings.

Optional Field: action

The action field defines the behavior of your extension's toolbar button, often called the 'browser action' button. This is the icon next to the address bar.

It commonly points to an HTML file (a "popup") that appears when the button is clicked, allowing for quick user interaction with your extension's UI.

A More Detailed Manifest

Let's expand our manifest to include a description, icons, and an action popup. This gives your extension a clear identity and a basic interactive element.

{
  "manifest_version": 3,
  "name": "My Awesome Extension",
  "version": "1.0",
  "description": "A simple extension to do awesome things!",
  "icons": {
    "16": "icons/icon16.png",
    "48": "icons/icon48.png",
    "128": "icons/icon128.png"
  },
  "action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "icons/icon16.png",
      "24": "icons/icon24.png",
      "32": "icons/icon32.png"
    },
    "default_title": "Click to open!"
  }
}

Quick Check on Manifest Fields

Based on what you've learned, identify the fields that are absolutely required in a Manifest V3 manifest.json file.

Manifest V3: Your Extension's Identity

We've explored the fundamental role of the manifest.json file, understanding it as the blueprint for your browser extension.

  • You learned about the three critical required fields: manifest_version (always 3), name, and version.
  • We also touched upon important optional fields like description, icons, and action, which define your extension's appearance and basic user interface.

Mastering the manifest file is the first step to building powerful and compliant browser extensions!

免费开始

用 AI 导师学习 JavaScript — 免费

在浏览器中编写并运行真实代码,获得全天候 AI 导师的即时帮助,并在网页或应用中继续学习。

课程
12
课程
48

常见问题解答

「理解 Manifest V3 结构」课时是免费的吗?

是的 — 「理解 Manifest V3 结构」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Browser Extensions Development (Chrome & Edge) 课程的其余内容,请升级到 CoddyKit PRO。 Browser Extensions Development (Chrome & Edge) 课程共包含 4 节课。

「理解 Manifest V3 结构」这节课中我会学到什么?

深入探索 manifest.json 文件,了解 Manifest V3 的必填字段和常见配置 你通过在浏览器中直接运行的动手代码来练习 Browser Extensions Development (Chrome & Edge),全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Browser Extensions Development (Chrome & Edge) 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Browser Extensions Development (Chrome & Edge) 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「理解 Manifest V3 结构」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Browser Extensions Development (Chrome & Edge) 课中编写并运行代码吗?

能。每节 Browser Extensions Development (Chrome & Edge) 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 理解 Manifest V3 结构
  2. 后台服务工作线程
  3. 权限与主机匹配
  4. 操作、图标与工具栏按钮
← 返回 Browser Extensions Development (Chrome & Edge)