gpt4 book ai didi

google-chrome - Chrome 扩展 : How to create context menu with custom name, 而不是插件名称

转载 作者:行者123 更新时间:2023-12-01 08:53:55 25 4
gpt4 key购买 nike

我正在尝试创建一个基本的 chrome 扩展。后发现root context menu can only contain one item per plugin ,我希望至少能够为父级命名而不是我的插件名称:

chrome.contextMenus.create({
title: "Child Item 1",
contexts:["selection"],
});
chrome.contextMenus.create({
title: "Child Item 2",
contexts:["selection"],
});

http://i.imgur.com/hsObtyL.png

那我该怎么做呢?

最佳答案

我这样做的方法是创建一个带有自定义 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",
});

结果如下:

Result

关于google-chrome - Chrome 扩展 : How to create context menu with custom name, 而不是插件名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32633433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com