Skip to content

Instantly share code, notes, and snippets.

@furkankadioglu
Last active June 8, 2017 17:08
Show Gist options
  • Save furkankadioglu/e9fd0ca7eb39daf31f529fb1969bbc70 to your computer and use it in GitHub Desktop.
Save furkankadioglu/e9fd0ca7eb39daf31f529fb1969bbc70 to your computer and use it in GitHub Desktop.
chromeActions
export function getChromeInformations() {
var eKey, aKey, authCheck;
return storageGet("eKey")
.then(function(_eKey){
console.log("Begin the promise function");
if("undefined" === typeof _eKey || _eKey == "" || _eKey == null)
{
var u1 = Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
storageSet("eKey", u1).then(function(response){
eKey = u1;
});
}
else
{
eKey = _eKey;
}
return storageGet("aKey");
})
.then(function(_aKey){
aKey = _aKey;
return storageGet("authCheck");
})
.then(function(_authCheck){
authCheck = "WHATEVER";
console.log(aKey);
console.log(eKey);
return {
type: "GET_CHROME_INFORMATIONS",
payload: {
eKey: eKey,
aKey: aKey
}
}
});
}
export function storageGet(key)
{
var privateData;
return new Promise(function(resolve, reject) {
chrome.storage.sync.get(key, function(data) {
privateData = data[key];
resolve(privateData);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment