ultrawidify/js/lib/StorageManager.js
2017-12-29 23:34:40 +01:00

32 lines
837 B
JavaScript

// setopt, getopt, delopt. Shrani oz. dobi oz. briše stvari iz skladišča
// setopt, getopt, delopt. They set/get/delete stuff from the storage
var _sm_setopt = function(item){
return browser.storage.local.set(item);
}
var _sm_getopt = function(prop, callback){
if(BrowserDetect.usebrowser == "chrome")
return browser.storage.local.get(prop, callback);
else
return browser.storage.local.get(prop).then(callback);
}
var _sm_getopt_async = async function(prop){
if(BrowserDetect.usebrowser == "chrome")
return await browser.storage.local.get(prop);
else
return await browser.storage.local.get(prop);
}
var _sm_delopt = function(item){
return browser.storage.local.remove(item);
}
var StorageManager = {
setopt: _sm_setopt,
getopt: _sm_getopt,
delopt: _sm_delopt,
getopt_async: _sm_getopt_async
}