]> git.r.bdr.sh - rbdr/junction/commitdiff
Add firefox extension rbdr-setup-extension
authorRuben Beltran del Rio <redacted>
Sun, 27 Sep 2020 15:31:21 +0000 (17:31 +0200)
committerRuben Beltran del Rio <redacted>
Sun, 27 Sep 2020 15:31:21 +0000 (17:31 +0200)
.gitignore [new file with mode: 0644]
CHANGELOG.md [moved from CHANGELOG with 72% similarity]
README.md
extension/icons/action-16.png [new file with mode: 0644]
extension/icons/action-32.png [new file with mode: 0644]
extension/icons/hang_up-16.png [new file with mode: 0644]
extension/icons/hang_up-32.png [new file with mode: 0644]
extension/icons/junction.png [new file with mode: 0644]
extension/junction.js [new file with mode: 0644]
extension/manifest.json [new file with mode: 0644]
extension/sounds/tada.wav [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..9daa824
--- /dev/null
@@ -0,0 +1,2 @@
+.DS_Store
+node_modules
similarity index 72%
rename from CHANGELOG
rename to CHANGELOG.md
index 9d39e43305436d79fb711a8d9a95b54687384a9a..0d49813c5c47575c80ba9a9ff0102cd2ce360cd0 100644 (file)
--- a/CHANGELOG
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ## [Unreleased]
 ### Added
 - This changelog
+- Firefox extension configuration
+- Rudimentary state control in the extension
 
 [Unreleased]: https://gitlab.com/rbdr/junction/compare/v1.0.0...HEAD
-[1.0.0]: https://gitlab.com/rbdr/junction/releases/tag/v1.0.0
\ No newline at end of file
+[1.0.0]: https://gitlab.com/rbdr/junction/releases/tag/v1.0.0
index 18d572bca06fa66552f009c7e6ec5f4ef3257140..9e420d34a0c58b5aead57236bd383063dbac894d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,13 @@
 # Junction
 
-Connect people through any URL
\ No newline at end of file
+Connect people through any URL
+
+## Extension
+
+### Testing on Firefox
+
+In order to test on firefox, first go to `about:debugging`, then click
+on the `This Firefox` option. Then click on `Load Temporary Add-On` and
+point the browser to the `extension/manifest.json` file.
+
+This will enable the extension and will allow you to use the inspector to debug.
diff --git a/extension/icons/action-16.png b/extension/icons/action-16.png
new file mode 100644 (file)
index 0000000..eb855e2
Binary files /dev/null and b/extension/icons/action-16.png differ
diff --git a/extension/icons/action-32.png b/extension/icons/action-32.png
new file mode 100644 (file)
index 0000000..c2da8b5
Binary files /dev/null and b/extension/icons/action-32.png differ
diff --git a/extension/icons/hang_up-16.png b/extension/icons/hang_up-16.png
new file mode 100644 (file)
index 0000000..b9d7515
Binary files /dev/null and b/extension/icons/hang_up-16.png differ
diff --git a/extension/icons/hang_up-32.png b/extension/icons/hang_up-32.png
new file mode 100644 (file)
index 0000000..08970a7
Binary files /dev/null and b/extension/icons/hang_up-32.png differ
diff --git a/extension/icons/junction.png b/extension/icons/junction.png
new file mode 100644 (file)
index 0000000..acdf012
Binary files /dev/null and b/extension/icons/junction.png differ
diff --git a/extension/junction.js b/extension/junction.js
new file mode 100644 (file)
index 0000000..7de7c28
--- /dev/null
@@ -0,0 +1,64 @@
+const internals = {
+
+  isInCallState: false,
+
+  icons: {
+    call: {
+      16: 'icons/action-16.png',
+      32: 'icons/action-32.png'
+    },
+
+    hangUp: {
+      16: 'icons/hang_up-16.png',
+      32: 'icons/hang_up-32.png'
+    }
+  },
+
+  onClick() {
+    if (internals.isInCall()) {
+      return internals.hangUp();
+    }
+
+    return internals.joinAudioCall();
+  },
+
+  async joinAudioCall() {
+
+    internals.isInCallState = true;
+    internals.setIcon('hangUp');
+    const tabs = await browser.tabs.query({
+      currentWindow: true,
+      active: true
+    });
+
+    internals.createAudioElement(browser.runtime.getURL('sounds/tada.wav'));
+  },
+
+  hangUp() {
+
+    document.querySelectorAll('audio').forEach((audioElement) => audioElement.remove());
+    internals.setIcon('call');
+    internals.isInCallState = false;
+  },
+
+  createAudioElement(source) {
+
+    const audioElement = document.createElement('audio');
+    audioElement.src = source;
+    audioElement.autoplay = 'autoplay';
+    document.querySelector('body').appendChild(audioElement);
+  },
+
+  isInCall() {
+    return internals.isInCallState; // this should be replaced with actually checking the built stuff
+  },
+
+  setIcon(iconSet) {
+
+    browser.browserAction.setIcon({
+      path: internals.icons[iconSet]
+    });
+  }
+};
+
+browser.browserAction.onClicked.addListener(internals.onClick);
diff --git a/extension/manifest.json b/extension/manifest.json
new file mode 100644 (file)
index 0000000..df3ecc4
--- /dev/null
@@ -0,0 +1,25 @@
+{
+  "manifest_version": 2,
+  "name": "Junction",
+  "version": "1.0.0",
+  "description": "Jump into an audio call on any URL",
+
+  "permissions": [
+    "activeTab"
+  ],
+
+  "icons": {
+    "48": "icons/junction.png"
+  },
+
+  "background": {
+    "scripts": ["junction.js"]
+  },
+
+  "browser_action": {
+    "default_icon": {
+      "16": "icons/action-16.png",
+      "32": "icons/action-32.png"
+    }
+  }
+}
diff --git a/extension/sounds/tada.wav b/extension/sounds/tada.wav
new file mode 100644 (file)
index 0000000..b3127d1
Binary files /dev/null and b/extension/sounds/tada.wav differ