ultrawidify/js/lib/StorageManager.js

32 lines
837 B
JavaScript
Raw Normal View History

2017-10-02 23:30:40 +02:00
// 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){
2017-12-17 22:56:07 +01:00
return browser.storage.local.set(item);
2017-10-02 23:30:40 +02:00
}
var _sm_getopt = function(prop, callback){
if(BrowserDetect.usebrowser == "chrome")
2017-12-17 22:56:07 +01:00
return browser.storage.local.get(prop, callback);
2017-10-02 23:30:40 +02:00
else
2017-12-17 22:56:07 +01:00
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);
}
2017-10-02 23:30:40 +02:00
var _sm_delopt = function(item){
2017-12-17 22:56:07 +01:00
return browser.storage.local.remove(item);
2017-10-02 23:30:40 +02:00
}
var StorageManager = {
setopt: _sm_setopt,
getopt: _sm_getopt,
delopt: _sm_delopt,
getopt_async: _sm_getopt_async
2017-10-02 23:30:40 +02:00
}