First use the get
method and then use set
inside the get
callback to add your new storage data as a key/value pair to the storage object returned from get
. Example:
chrome.storage.local.get(function(cfg) {
if(typeof(cfg["key"]) !== 'undefined' && cfg["key"] instanceof Array) {
cfg["key"].push("value");
} else {
cfg["key"] = ["value"];
}
chrome.storage.local.set(cfg);
});