DEV Community

panfan
panfan

Posted on • Originally published at manon.icu on

Chrome插件开发 - Icon action

浏览器扩展图标 - action

修改public/manifest.json

{
  "action": {},
  "background": {
    "service_worker": "background.js"
  }
}
Enter fullscreen mode Exit fullscreen mode

修改public/background.js

chrome.action.onClicked.addListener(() => {
  chrome.tabs.create({url: './new-tab.html', active: true})
})
Enter fullscreen mode Exit fullscreen mode

当点击图标,将会导航到新的选项卡

Source Code

【Source Code】

Top comments (0)