]>
git.r.bdr.sh - rbdr/junction/blob - extension/src/junction.js
3 promisesSupported: !!(window
.browser
),
8 16: 'icons/action-16.png',
9 32: 'icons/action-32.png'
13 16: 'icons/hang_up-16.png',
14 32: 'icons/hang_up-32.png'
19 if (internals
.isInCall()) {
20 return internals
.hangUp();
23 return internals
.joinAudioCall();
26 async
joinAudioCall() {
28 internals
.isInCallState
= true;
29 internals
.setIcon('hangUp');
30 const activeTabs
= await internals
.getActiveTabs();
32 console
.log(activeTabs
[0].url
); // placeholder while we connect backend.
33 internals
.createAudioElement(internals
.getRoot().runtime
.getURL('sounds/tada.wav'));
38 document
.querySelectorAll('audio').forEach((audioElement
) => audioElement
.remove());
39 internals
.setIcon('call');
40 internals
.isInCallState
= false;
43 createAudioElement(source
, type
= 'audio/wav') {
45 const audioElement
= document
.createElement('audio');
46 audioElement
.src
= source
;
47 audioElement
.autoplay
= 'autoplay';
48 audioElement
.type
= type
;
49 document
.querySelector('body').appendChild(audioElement
);
53 return internals
.isInCallState
; // this should be replaced with actually checking the built stuff
58 internals
.getRoot().browserAction
.setIcon({
59 path: internals
.icons
[iconSet
]
65 return window
.browser
|| window
.chrome
;
68 // Chrome doesn't yet implement the promise based tabs.query :'(
77 if (internals
.promisesSupported
) {
78 return internals
.getRoot().tabs
.query(query
);
81 return new Promise((resolve
, reject
) => {
83 internals
.getRoot().tabs
.query(query
, (tabs
) => {
91 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);