考虑下面显示的示例,该示例取自MDN,并稍作修改以在侧边栏文件夹中包含两个侧边栏面板:
var thisPanel = browser.extension.getURL("/sidebar/this.html");
var thatPanel = browser.extension.getURL("/sidebar/that.html");
function toggle(panel) {
if (panel === thisPanel) {
browser.sidebarAction.setPanel({panel: thatPanel});
} else {
browser.sidebarAction.setPanel({panel: thisPanel});
}
}
browser.browserAction.onClicked.addListener(() => {
browser.sidebarAction.getPanel({}).then(toggle);
});
如何在manifest.json中定义sidebar_action属性?可以吗?
"sidebar_action": {
"default_icon": "/icons/default_icon.svg",
"default_title" : "Title",
"default_panel": "/sidebar/this.html",
"open_at_install": false
},