]>
git.r.bdr.sh - rbdr/junction/blob - extension/junction.js
575a716b20d83c825898befe01cb225e68578c48
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 console
.log('setting tabs');
31 const activeTabs
= await internals
.getActiveTabs();
33 console
.log(activeTabs
[0].url
); // placeholder while we connect backend.
34 internals
.createAudioElement(internals
.getRoot().runtime
.getURL('sounds/tada.wav'));
39 document
.querySelectorAll('audio').forEach((audioElement
) => audioElement
.remove());
40 internals
.setIcon('call');
41 internals
.isInCallState
= false;
44 createAudioElement(source
, type
= 'audio/wav') {
46 const audioElement
= document
.createElement('audio');
47 audioElement
.src
= source
;
48 audioElement
.autoplay
= 'autoplay';
49 audioElement
.type
= type
;
50 document
.querySelector('body').appendChild(audioElement
);
54 return internals
.isInCallState
; // this should be replaced with actually checking the built stuff
59 internals
.getRoot().browserAction
.setIcon({
60 path: internals
.icons
[iconSet
]
66 return window
.browser
|| window
.chrome
;
69 // Chrome doesn't yet implement the promise based tabs.query :'(
78 if (internals
.promisesSupported
) {
79 return internals
.getRoot().tabs
.query(query
);
82 return new Promise((resolve
, reject
) => {
84 internals
.getRoot().tabs
.query(query
, (tabs
) => {
92 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);