I'm trying to create a basic chrome extension. After finding out that the root context menu can only contain one item per plugin, I wanted to at least be able to name the parent something else than my plugin name:
chrome.contextMenus.create({
title: "Child Item 1",
contexts:["selection"],
});
chrome.contextMenus.create({
title: "Child Item 2",
contexts:["selection"],
});
So how do I do that?
The way I did it, was to create a parent item with a custom title
and id
, and then adding all the items I needed, as children to the parent item (to my script.js
file):
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",
});
Here's the result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With