From: Ruben Beltran del Rio Date: Sun, 27 Sep 2020 15:31:21 +0000 (+0200) Subject: Add firefox extension X-Git-Url: https://git.r.bdr.sh/rbdr/junction/commitdiff_plain/1ed219c8314a0ca1b95ef8593bb608b7659c87a3?ds=inline;hp=1aefbf569ac489946e2552ce6c10697c67ea55b8 Add firefox extension --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9daa824 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +node_modules diff --git a/CHANGELOG b/CHANGELOG.md similarity index 72% rename from CHANGELOG rename to CHANGELOG.md index 9d39e43..0d49813 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 18d572b..9e420d3 100644 --- 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 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 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 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 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 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 index 0000000..7de7c28 --- /dev/null +++ b/extension/junction.js @@ -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 index 0000000..df3ecc4 --- /dev/null +++ b/extension/manifest.json @@ -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 index 0000000..b3127d1 Binary files /dev/null and b/extension/sounds/tada.wav differ