我正在使用chrome.contextMenus.create函数在我的Chrome扩展程序中创建上下文菜单.但它创造了额外的选择.
我在我的manifest.json文件中给了权限,将此函数添加到我的background.js文件中并将其添加到我的manifest.json文件中.
为什么会这样?
function getword(info,tab) {
console.log("Word " + info.selectionText + " was clicked.");
chrome.tabs.create({
url: "http://www.google.com/search?q=" + info.selectionText,
});
}
chrome.contextMenus.create({
title: "Search: %s",
contexts:["selection"],
onclick: getword,
});
Run Code Online (Sandbox Code Playgroud)
javascript google-chrome contextmenu google-chrome-extension