Last active
June 8, 2017 17:08
-
-
Save furkankadioglu/e9fd0ca7eb39daf31f529fb1969bbc70 to your computer and use it in GitHub Desktop.
chromeActions
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
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