A while ago I could save ID of the created item for the context menu in Google Chrome Extensions:
background.js:
var myItem;
if (myItem !== "MyItem") {
myItem = chrome.contextMenus.create({
title: "My item",
id: 'MyItem',
contexts: ["page"]
});
}
But now when I open Chrome first it says:
Unchecked runtime.lastError while running contextMenus.create: Cannot create item with duplicate id MyItem
(from debug console)
So it doesn't remember my variable "myItem" (its data) anymore when I close Chrome. It only remembers while Chrome is opened.
So now should I use chrome.storage.local.get
or set
to save ID of my Context Menu Items?
Update:
The problem was a "persistent": false
in manifest for background:
"background": {
"scripts": [ "background.js" ]
},
Removed it & now it works normally [Solved]