(二)Manifest文件结构

本文介绍了JSON数据结构的两种形式:键值对与纯值,并通过《哈利·波特》的例子进行说明。此外,详细列举了Chrome扩展Manifest文件的必备内容及可选配置项,帮助开发者快速掌握Manifest文件的编写。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. json 有两种结构
    一种是键值对,即key:value
    json1

    一种是纯值的
    json2

    举个栗子:

    {
        "name" : "Harry Potter",
        "author" : {
            "name" : "J.K.Rowling",
            "birth" : 1964
        },
        "books" : [
            "Philosopher's Stone",
            "Chamber of Secrets",
            "Prisoner of Azkaban",
            "Goblet of Fire",
            "Order of the Phoenix",
            "Half-Blood Prince",
            "Deathly Hallows"
        ]
    }
  2. manifest 必备内容

    • Chrome扩展的Manifest 必须 包含nameversionmanifest_version属性,目前来说manifest_version属性值只能为数字2,对于应用来说,还必须包含app属性。
  3. 可套用模板

{
    "app": {
        "background": {
            "scripts": ["background.js"]
        }
    },
    "manifest_version": 2,
    "name": "My Extension",
    "version": "versionString",
    "default_locale": "en",
    "description": "A plain text description",
    "icons": {
        "16": "images/icon16.png",
        "48": "images/icon48.png",
        "128": "images/icon128.png"
    },
    "browser_action": {
        "default_icon": {
            "19": "images/icon19.png",
            "38": "images/icon38.png"
        },
        "default_title": "Extension Title",
        "default_popup": "popup.html"
    },
    "page_action": {
        "default_icon": {
            "19": "images/icon19.png",
            "38": "images/icon38.png"
        },
        "default_title": "Extension Title",
        "default_popup": "popup.html"
    },
    "background": {
        "scripts": ["background.js"]
    },
    "content_scripts": [
        {
            "matches": ["http://www.google.com/*"],
            "css": ["mystyles.css"],
            "js": ["jquery.js", "myscript.js"]
        }
    ],
    "options_page": "options.html",
    "permissions": [
        "*://www.google.com/*"
    ],
    "web_accessible_resources": [
        "images/*.png"
    ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值