]>
git.r.bdr.sh - rbdr/junction/blob - extension/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();
28 internals
.port
= port
;
29 port
.onDisconnect
.addListener(internals
.onDisconnect
);
30 port
.onMessage
.addListener(internals
.onMessage
);
32 action: 'joinAudioCall',
34 tada: internals
.getRoot().runtime
.getURL('sounds/tada.wav')
37 internals
.getRoot().browserAction
.enable();
38 internals
.setIcon('hangUp');
43 if (message
.action
=== 'error') {
44 internals
.getRoot().browserAction
.setBadgeText({ text: 'x' }, () => {});
49 internals
.getRoot().browserAction
.setBadgeText({ text: '' }, () => {});
50 internals
.setIcon('call');
51 internals
.port
= null;
52 internals
.getRoot().browserAction
.enable();
55 async
joinAudioCall() {
57 internals
.getRoot().browserAction
.disable();
58 const activeTabs
= await internals
.getActiveTabs();
60 const execution
= await internals
.getRoot().tabs
.executeScript(activeTabs
[0].id
, {
61 file: '/build/content_script.js'
64 if (!execution
|| !execution
[0]) {
65 internals
.onDisconnect();
72 internals
.getRoot().browserAction
.disable();
73 internals
.port
.postMessage({
80 return !!(internals
.port
);
85 internals
.getRoot().browserAction
.setIcon({
86 path: internals
.icons
[iconSet
]
92 return window
.browser
|| window
.chrome
;
95 // Chrome doesn't yet implement the promise based tabs.query :'(
104 if (internals
.promisesSupported
) {
105 return internals
.getRoot().tabs
.query(query
);
108 return new Promise((resolve
, reject
) => {
110 internals
.getRoot().tabs
.query(query
, (tabs
) => {
112 return resolve(tabs
);
118 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);
119 internals
.getRoot().runtime
.onConnect
.addListener(internals
.onConnect
);