From 4b19b3451738e8163c170506748cd033950914fa Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Thu, 12 Oct 2023 10:16:52 +1300 Subject: [PATCH 1/6] fix the build script --- build.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 432c990..c5fd8c1 100755 --- a/build.sh +++ b/build.sh @@ -8,23 +8,23 @@ rm -rf build mkdir -p build/chrome-dev cp -r src/shared/* build/chrome-dev cp -r src/chrome/* build/chrome-dev -sed -i "" "s~{{SERVER}}~$SERVER_DEV_ORIGIN~g" build/chrome-dev/api.js -sed -i "" "s~{{SERVER}}~$SERVER_DEV_HOST~g" build/chrome-dev/manifest.json +sed -i "s~{{SERVER}}~$SERVER_DEV_ORIGIN~g" build/chrome-dev/api.js +sed -i "s~{{SERVER}}~$SERVER_DEV_HOST~g" build/chrome-dev/manifest.json mkdir -p build/chrome-prod cp -r src/shared/* build/chrome-prod cp -r src/chrome/* build/chrome-prod -sed -i "" "s~{{SERVER}}~$SERVER_PROD_ORIGIN~g" build/chrome-prod/api.js -sed -i "" "s~{{SERVER}}~$SERVER_PROD_HOST~g" build/chrome-prod/manifest.json +sed -i "s~{{SERVER}}~$SERVER_PROD_ORIGIN~g" build/chrome-prod/api.js +sed -i "s~{{SERVER}}~$SERVER_PROD_HOST~g" build/chrome-prod/manifest.json mkdir -p build/firefox-dev cp -r src/shared/* build/firefox-dev cp -r src/firefox/* build/firefox-dev -sed -i "" "s~{{SERVER}}~$SERVER_DEV_ORIGIN~g" build/firefox-dev/api.js -sed -i "" "s~{{SERVER}}~$SERVER_DEV_HOST~g" build/firefox-dev/manifest.json +sed -i "s~{{SERVER}}~$SERVER_DEV_ORIGIN~g" build/firefox-dev/api.js +sed -i "s~{{SERVER}}~$SERVER_DEV_HOST~g" build/firefox-dev/manifest.json mkdir -p build/firefox-prod cp -r src/shared/* build/firefox-prod cp -r src/firefox/* build/firefox-prod -sed -i "" "s~{{SERVER}}~$SERVER_PROD_ORIGIN~g" build/firefox-prod/api.js -sed -i "" "s~{{SERVER}}~$SERVER_PROD_HOST~g" build/firefox-prod/manifest.json \ No newline at end of file +sed -i "s~{{SERVER}}~$SERVER_PROD_ORIGIN~g" build/firefox-prod/api.js +sed -i "s~{{SERVER}}~$SERVER_PROD_HOST~g" build/firefox-prod/manifest.json \ No newline at end of file From 5ce589d97f0d0b555597e5d4d3e71c3f3fa9d6cf Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Thu, 12 Oct 2023 11:31:44 +1300 Subject: [PATCH 2/6] sidebar --- src/chrome/manifest.json | 5 +- src/firefox/manifest.json | 8 ++ src/shared/background.js | 27 ++++- src/shared/popup/sidebar.html | 216 ++++++++++++++++++++++++++++++++++ 4 files changed, 251 insertions(+), 5 deletions(-) create mode 100644 src/shared/popup/sidebar.html diff --git a/src/chrome/manifest.json b/src/chrome/manifest.json index 532eb4f..280fd46 100644 --- a/src/chrome/manifest.json +++ b/src/chrome/manifest.json @@ -6,11 +6,14 @@ "icons": { "64": "icons/64.png" }, - "permissions": ["storage"], + "permissions": ["storage", "contextMenus", "sidePanel"], "host_permissions": ["*://{{SERVER}}/*"], "action": { "default_popup": "popup/index.html" }, + "side_panel": { + "default_path": "popup/sidebar.html" + }, "content_scripts": [ { "matches": ["*://{{SERVER}}/*"], diff --git a/src/firefox/manifest.json b/src/firefox/manifest.json index 0a6a98b..bd1abc7 100644 --- a/src/firefox/manifest.json +++ b/src/firefox/manifest.json @@ -11,6 +11,14 @@ "default_popup": "popup/index.html", "default_area": "navbar" }, + "sidebar_action": { + "default_icon": { + "64": "icons/64.png" + }, + "default_title": "Sidebox", + "default_panel": "popup/sidebar.html", + "open_at_install": true + }, "content_scripts": [ { "matches": ["*://{{SERVER}}/*"], diff --git a/src/shared/background.js b/src/shared/background.js index 8e65488..c3c2edc 100644 --- a/src/shared/background.js +++ b/src/shared/background.js @@ -5,10 +5,29 @@ chrome.runtime.onMessage.addListener((request, sender) => { const params = new URL(sender.tab.url).searchParams const code = params.get("code") const state = params.get("state") - + if (code) - new API().login(code, state).then(({ token }) => { - chrome.storage.local.set({ token }) - }) + new API().login(code, state).then(({ token }) => { + chrome.storage.local.set({ token }) + }) } }) + +chrome.runtime.onInstalled.addListener(() => { + chrome.contextMenus.removeAll(); + if (chrome.sidePanel) { + chrome.contextMenus.create({ + id: "open-sidebar", + title: "Open in sidebar", + contexts: ["action"] + }) + } +}) + +if (chrome.sidePanel) { + chrome.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId === "open-sidebar") { + chrome.sidePanel.open({ windowId: tab.windowId }) + } + }) +} diff --git a/src/shared/popup/sidebar.html b/src/shared/popup/sidebar.html new file mode 100644 index 0000000..11760a7 --- /dev/null +++ b/src/shared/popup/sidebar.html @@ -0,0 +1,216 @@ + + + + + + + +
+
+ +
+
+ +
+
+

Sidebox

+ + +
+ +
+ +
+ +
+
+ +
+
+
+ + +
+ + + + + +
+
+ +

+ +
+ +

Loading...

+

Nothing here yet!

+
+ +
+ +
+ +
+ +
+
+ +
+
+
+ + +

+

+

+
+ + +
+
+ + + + From 2b8daa5653fa563e53afd4f550f34bde497b676d Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Thu, 12 Oct 2023 12:54:49 +1300 Subject: [PATCH 3/6] "cleanup" stuff for consistent button placement --- src/shared/popup/index.html | 43 +++++++++++++++---------- src/shared/popup/scripts/util/screen.js | 5 +-- src/shared/popup/sidebar.html | 4 +-- src/shared/popup/styles/header.css | 22 +++++++++++++ src/shared/popup/styles/home.css | 15 +++++++-- src/shared/popup/styles/inbox.css | 23 ------------- src/shared/popup/styles/main.css | 27 +++++++++++++++- 7 files changed, 91 insertions(+), 48 deletions(-) create mode 100644 src/shared/popup/styles/header.css diff --git a/src/shared/popup/index.html b/src/shared/popup/index.html index c454350..50ec1a4 100644 --- a/src/shared/popup/index.html +++ b/src/shared/popup/index.html @@ -4,7 +4,7 @@ - +
@@ -15,23 +15,32 @@

Sidebox

- +
+ + +
-
+