I would like to add a context menu option “Bookmark This Link Now” which will be like “Bookmark This Link” but will skip the dialog box, which I always just hit “Save” on anyway. The following works except that I don’t know how to set the title of the link. “Bookmark This Link” seems to create the title from the text of the link, i.e., the text between the <a> and </a>
. How can I read this text? In the code below the url is sent in the info object, but the text is not. This is what I have so far:
browser.contextMenus.create({
id: "bookmark-now",
title: "Bookmark This Link Now",
contexts: ["link"]
}, null);
browser.contextMenus.onClicked.addListener(function(info, tab) {
switch (info.menuItemId) {
case "bookmark-now":
browser.bookmarks.create(
{
// parentId: "", // leaving this out uses default, which is good
// title: "", // How to set the title?
url: info.linkUrl
}
);
break;
}
});