Initial extension commit

This commit is contained in:
ronreg-ribdev 2020-11-28 00:08:38 -08:00
commit 0736a5870d
9 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1 @@
console.log("Executing Urbit extension background main script");

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="module" src="main.js"></script>
</head>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

37
extension/manifest.json Normal file
View File

@ -0,0 +1,37 @@
{
"manifest_version": 2,
"name": "Urbit Browser Manager",
"version": "0.0.1",
"description": "Manage your web browsing with your Urbit ship",
"homepage_url": "https://example.com",
"icons": {
"48": "icons/urbit-icon.png"
},
"permissions": [
"activeTab", "storage"
],
"background": {
"page": "background/page.html"
},
"options_ui": {
"page": "options/options.html",
"browser_style": true
},
"browser_action": {
"default_icon": "icons/urbit-icon.png",
"default_title": "Urbit Browser Manager",
"default_popup": "popup/popup.html"
},
"browser_specific_settings": {
"gecko": {
"id": "ronreg-ribdev@urbit.live"
}
}
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<form>
<label>Urbit ID</label>
<input type="text" id="urbitId"/>
<label>Code</label>
<input id="urbitCode" type="password" id="urbit_code"/>
<button id="saveButton">Save</button>
<button id="clearButton">Clear</button>
</form>
<script src="options.js"></script>
</body>
</html>

View File

@ -0,0 +1,26 @@
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");
});

View File

@ -0,0 +1,8 @@
html, body {
width: 200px;
}
h1 {
font-size: large;
}

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popp.css"/>
</head>
<body>
<h1>Urbit browser manager</h1>
<span id="loggedInMsg"></span>
<main>
Managing this page?
<button id="options">Options</button>
</main>
<script src="popup.js"></script>
</body>
</html>

16
extension/popup/popup.js Normal file
View File

@ -0,0 +1,16 @@
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";
}
});