urbit-browser-manager/extension/options/options.js
ronreg-ribdev 703a0cd630 Get rid of src/ dir
don't need this layer of indirection
2021-01-02 23:47:15 -08:00

29 lines
977 B
JavaScript

const browser = require("webextension-polyfill");
const urbitIdSelector = document.querySelector("#urbitId");
const urbitCodeSelector = document.querySelector("#urbitCode");
document.addEventListener('DOMContentLoaded', () => {
browser.storage.sync.get("credentials")
.then((result) => {
if (result.credentials && result.credentials.urbitId && result.credentials.urbitCode) {
urbitIdSelector.value = result.credentials.urbitId;
urbitCodeSelector.value = result.credentials.urbitCode;
} else {
urbitIdSelector.value = "";
urbitCodeSelector.value = "";
}
});
});
document.querySelector("#saveButton").addEventListener("click", () => {
const urbitId = urbitIdSelector.value;
const urbitCode = urbitCodeSelector.value;
browser.storage.sync.set({credentials: {urbitId, urbitCode}});
});
document.querySelector("#clearButton").addEventListener("click", () => {
browser.storage.sync.remove("credentials");
});