I have a chunk of code:
for (game in settings_object.games)
{
chrome.contextMenus.create({
"title": "Add thread("+request.thread+") to game: "+game,
"contexts":["page"],
"onclick": function () {addThreadToGame(game,request.thread)}
});
}
That generates a context menue like:
- Add thread (1234) to game: ID of Game One
- Add thread (1234) to game: ID of Game Two
- Add thread (1234) to game: ID of Game Three
and the intention is for when the user clicks on “Add thread (1234) to game: ID of Game One” then addThreadToGame(“ID of Game One”, “1234”) get’s executed… unfortunately it seems like addThreadToGame is always triggered as addThreadToGame (“ID of Game Three”, “1234”) because the value being passed to the function is always the last value it has at run time not menu generation time… what am I missing?
Worked out the answer:
after adapting the code I found in selection and site search in chrome extension