Я пытаюсь добавить элемент контекстного меню в расширение браузера Microsoft Edge, но он вообще не отображается.
Я использую Windows 10 Insider Preview Build 14372.
Я просмотрел документацию по поддерживаемым API в котором говорится, что API contextMenus поддерживается в браузере Edge.
manifest.json
{
"manifest_version": 2,
"name": "Sample Context Menu",
"version": "1.0.0",
"description": "Adds a context menu item when you select some text",
"author": "author_name",
"icons": {
"16": "icon/icon16.png",
"32": "icon/icon32.png",
"48": "icon/icon48.png",
"128": "icon/icon128.png"
},
"permissions": ["contextMenus"],
"background": {
"scripts": ["index.js"],
"persistent": true
}
}
index.js
chrome.contextMenus.create({
id: "sample",
title: "Sample Context Menu",
contexts: ['selection']
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId == "sample") {
var selected_text = info.selectionText;
console.log(selected_text);
}
});
Я получаю сообщение об ошибке Script5007: Unable to get property 'create' of undefined or null reference при просмотре консоли разработчика.