我需要创建一个上下文菜单选项来搜索所选文本或链接。我需要能够在上下文菜单的标题中显示文本或链接,但只能显示所选文本。如何在菜单项标题中显示链接的网址?
代码:
function searchGoogle(info, tab) {
chrome.tabs.create({
url: "http://www.google.com/search?q=" + info.selectionText,
});
}
chrome.contextMenus.create({
title: "Search %s", //I want to display selection AND link url
contexts:["link", "selection"],
});