Files
webextensions-examples/stored-credentials/storage.js
rebloor 82217a05bc Replace var with let in examples (#484)
* Replace var with let in examples

store-collected-images/webextension-plain/deps/uuidv4.js

* Reverted third–party code
2022-08-11 04:27:28 +12:00

28 lines
566 B
JavaScript

/*
Default settings. Initialize storage to these values.
*/
let 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);