Ask*_* B. 3 google-chrome contextmenu google-chrome-extension
我正在尝试创建一个基本的chrome扩展.在发现根上下文菜单每个插件只能包含一个项目之后,我想至少能够为父项命名除了我的插件名称之外的其他内容:
chrome.contextMenus.create({
title: "Child Item 1",
contexts:["selection"],
});
chrome.contextMenus.create({
title: "Child Item 2",
contexts:["selection"],
});
Run Code Online (Sandbox Code Playgroud)
那我该怎么做?
我所采取的方式,是一个自定义创建父项目title和id,然后将我需要的所有物品,因为儿童的父项(我的script.js文件):
chrome.contextMenus.create({
title: "Custom Parent Name",
contexts:["selection"],
id: "parent",
});
chrome.contextMenus.create({
title: "Child Item 1",
contexts:["selection"],
parentId: "parent",
id: "child1",
});
chrome.contextMenus.create({
title: "Child Item 2",
contexts:["selection"],
parentId: "parent",
id: "child2",
});
Run Code Online (Sandbox Code Playgroud)
这是结果:
| 归档时间: |
|
| 查看次数: |
1229 次 |
| 最近记录: |