Initial extension commit
This commit is contained in:
commit
0736a5870d
1
extension/background/main.js
Normal file
1
extension/background/main.js
Normal file
@ -0,0 +1 @@
|
||||
console.log("Executing Urbit extension background main script");
|
7
extension/background/page.html
Normal file
7
extension/background/page.html
Normal file
@ -0,0 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="module" src="main.js"></script>
|
||||
</head>
|
||||
</html>
|
BIN
extension/icons/urbit-icon.png
Normal file
BIN
extension/icons/urbit-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
37
extension/manifest.json
Normal file
37
extension/manifest.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
extension/options/options.html
Normal file
19
extension/options/options.html
Normal 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>
|
26
extension/options/options.js
Normal file
26
extension/options/options.js
Normal 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");
|
||||
});
|
||||
|
8
extension/popup/popup.css
Normal file
8
extension/popup/popup.css
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
html, body {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: large;
|
||||
}
|
17
extension/popup/popup.html
Normal file
17
extension/popup/popup.html
Normal 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
16
extension/popup/popup.js
Normal 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";
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user