Files
webextensions-examples/stored-credentials/storage.js
wbamberg 5dd59a4028 Example of the webRequest.onAuthRequired API (#206)
* Example of the webRequest.onAuthRequired API

* Update README, add applications.id to manifest
2017-04-14 13:34:05 -07:00

28 lines
566 B
JavaScript

/*
Default settings. Initialize storage to these values.
*/
var authCredentials = {
username: "user",
password: "passwd"
}
/*
Generic error logger.
*/
function onError(e) {
console.error(e);
}
/*
On startup, check whether we have stored settings.
If we don't, then store the default settings.
*/
function checkStoredSettings(storedSettings) {
if (!storedSettings.authCredentials) {
browser.storage.local.set({authCredentials});
}
}
const gettingStoredSettings = browser.storage.local.get();
gettingStoredSettings.then(checkStoredSettings, onError);