urbit-browser-manager/extension/popup/popup.js

19 lines
585 B
JavaScript
Raw Permalink Normal View History

2021-01-02 23:16:22 -08:00
const browser = require("webextension-polyfill");
2020-11-28 00:08:38 -08:00
console.log("popup.js running");
const getLocalStorage = browser.storage.sync.get();
document.querySelector("#options").addEventListener("click", () => {
browser.runtime.openOptionsPage();
});
getLocalStorage.then((result) => {
const loggedInSelector = document.querySelector("#loggedInMsg");
if (result.credentials && result.credentials.urbitId && result.credentials.urbitCode) {
loggedInSelector.textContent = `Hi, ~${result.credentials.urbitId}`;
} else {
loggedInSelector.textContent = "Not logged in";
}
});