I'm trying to add a context menu item to a Microsoft Edge browser extension, but it is not showing up at all.
I am using the Windows 10 Insider Preview Build 14372
I have looked at the documentation for supported apis which says that the contextMenus API are supported in the Edge browser.
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);
}
});
I'm getting Script5007: Unable to get property 'create' of undefined or null reference error message when I look at the Developer Console.