commit 0736a5870d4fbad9be374e4e05e47d9697e0bd0f Author: ronreg-ribdev Date: Sat Nov 28 00:08:38 2020 -0800 Initial extension commit diff --git a/extension/background/main.js b/extension/background/main.js new file mode 100644 index 0000000..249f91c --- /dev/null +++ b/extension/background/main.js @@ -0,0 +1 @@ +console.log("Executing Urbit extension background main script"); diff --git a/extension/background/page.html b/extension/background/page.html new file mode 100644 index 0000000..68e1c37 --- /dev/null +++ b/extension/background/page.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extension/icons/urbit-icon.png b/extension/icons/urbit-icon.png new file mode 100644 index 0000000..0f4b25d Binary files /dev/null and b/extension/icons/urbit-icon.png differ diff --git a/extension/manifest.json b/extension/manifest.json new file mode 100644 index 0000000..34504ef --- /dev/null +++ b/extension/manifest.json @@ -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" + } + } +} + diff --git a/extension/options/options.html b/extension/options/options.html new file mode 100644 index 0000000..50939a5 --- /dev/null +++ b/extension/options/options.html @@ -0,0 +1,19 @@ + + + + + + + + +
+ + + + + + +
+ + + diff --git a/extension/options/options.js b/extension/options/options.js new file mode 100644 index 0000000..159170e --- /dev/null +++ b/extension/options/options.js @@ -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"); +}); + diff --git a/extension/popup/popup.css b/extension/popup/popup.css new file mode 100644 index 0000000..8f18db8 --- /dev/null +++ b/extension/popup/popup.css @@ -0,0 +1,8 @@ + +html, body { + width: 200px; +} + +h1 { + font-size: large; +} diff --git a/extension/popup/popup.html b/extension/popup/popup.html new file mode 100644 index 0000000..01873b0 --- /dev/null +++ b/extension/popup/popup.html @@ -0,0 +1,17 @@ + + + + + + + +

Urbit browser manager

+ +
+ Managing this page? + + +
+ + + diff --git a/extension/popup/popup.js b/extension/popup/popup.js new file mode 100644 index 0000000..e214664 --- /dev/null +++ b/extension/popup/popup.js @@ -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"; + } +});