I'm trying to display a different menu text based on the selection:
manifest.js:
{
"name": "Test app",
"description": "",
"version": "1.0.1",
"icons": {"16": "icons/16.png", "48": "icons/48.png", "128": "icons/128.png"},
"permissions": ["contextMenus"],
"background": {
"scripts": ["js/test.js"],
"persistent": true
},
"manifest_version": 2
}
js/test.js
function validateSelection(number) {
if (parseInt(number) > 5) {
return "Result: x > 5; (x = " + number +")";
} else {
return "Result: x <= 5; (x = " + number +")";
}
}
var s_item = chrome.contextMenus.create({"title" : validateSelection("%s") + " => Selection: %s",
"contexts": ["selection"],
"onclick" : genericOnClick,
"enabled" : true
});
However no matter what number I select I always get the output from the else
clause in my validateSelection()
function. What kind of object is passed to my function, is it string
? How otherwise I can validate the selection
?