chrome浏览器插件编写

在使用Chrome浏览器插件编写时,需要按照Manifest V3的规范来编写manifest.json文件。下面是一个示例:

{
  "manifest_version": 3,
  "name": "My Chrome Extension",
  "version": "1.0",
  "action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "images/icon16.png",
      "48": "images/icon48.png",
      "128": "images/icon128.png"
    },
    "default_title": "Click to open the extension"
  },
  "permissions": [
    "tabs"
  ],
  "icons": {
    "16": "images/icon16.png",
    "48": "images/icon48.png",
    "128": "images/icon128.png"
  },
  "background": {
    "service_worker": "background.js"
  },
  "action_types": [
    {
      "type": "tab",
      "default_popup": "popup.html",
      "browser_style": true
    }
  ],
  "chrome_url_overrides": {
    "newtab": "newtab.html"
  },
  "web_accessible_resources": [
    {
      "resources": [
        "images/*"
      ],
      "matches": [
        "https://example.com/*"
      ]
    }
  ]
}

上述示例中,manifest_version被设置为3,表示使用Manifest V3版本。其中包含了一些常用的字段,如nameversionaction等。具体根据你的插件需求来修改和添加其他字段。

请注意,Manifest V3与Manifest V2有一些重要的改变,例如background被替换为service_workerpage_action被替换为action等。建议阅读Chrome官方文档来了解更多关于Manifest V3的详细信息。

参考文档:

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值