-
-
Save MikeeI/1044feecf869be3744cc to your computer and use it in GitHub Desktop.
A simple, localStorage-like way to interact with Chrome's Storage API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scs = { | |
set: function(key,value,type) { | |
var kvo = {}; | |
kvo[key] = value; | |
var cs; | |
if (type == "local") { | |
cs = chrome.storage.local; | |
} else { | |
cs = chrome.storage.sync; | |
} | |
cs.set(kvo); | |
}, | |
get: function(key,type) { | |
var retVal; | |
var cs; | |
if (type == "local") { | |
cs = chrome.storage.local; | |
} else { | |
cs = chrome.storage.sync; | |
} | |
cs.get(key,function(r){ | |
retVal = r[key]; | |
}); | |
return retVal; | |
} | |
} | |
// scs.set("waffles",true) | |
// scs.get("waffles") | |
// --> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment