google chrome extension - Using Stored Data to Define Sub Menu Entries -


my extension should use user's options build submenus under main extension context menu entry. options stored in table, each line defining submenu. whole table stored json string in chrome.local.storage key jsondata.

the manifest is:

   "background": {   "persistent": true,   "scripts": [ "js/storage.js", "js/backgroundlib.js", "js/background.js" ] }, ... "permissions": [ "storage", "contextmenus", "http://*/*", "https://*/*",   "tabs", "clipboardread", "clipboardwrite" ], ... 

in background script, i'm trying data using:

window.addeventlistener('load', function () { var key = 'jsondata';   storage.area.get(key, function (items){       console.log(items[key]);      build_submenu(items[key]);});   });   function build_submenu(json) {      console.log("build_submenu: " + json);  } 

and build_submenu should call multiple chrome.contextmenus.create({... }) add submenus. now, can't build_submenu being called. trying not possible or missing obvious?

thanks, f.

replace storage.area.get chrome.storage.local.get.

another suggestion removing outer window.onload listener, since using background scripts , window.onload makes no sense.


Comments