]>
git.r.bdr.sh - rbdr/junction/blob - extension/junction.js
3 promisesSupported: !!(window
.browser
),
9 16: 'icons/action-16.png',
10 32: 'icons/action-32.png'
14 16: 'icons/hang_up-16.png',
15 32: 'icons/hang_up-32.png'
20 if (internals
.isInCall()) {
21 return internals
.hangUp();
24 return internals
.joinAudioCall();
29 internals
.port
= port
;
30 port
.onDisconnect
.addListener(internals
.onDisconnect
);
31 port
.onMessage
.addListener(internals
.onMessage
);
33 action: 'joinAudioCall',
35 currentUrl: internals
.currentUrl
,
36 tada: internals
.getRoot().runtime
.getURL('sounds/tada.wav')
39 internals
.getRoot().browserAction
.enable();
40 internals
.setIcon('hangUp');
45 if (message
.action
=== 'error') {
46 internals
.getRoot().browserAction
.setBadgeText({ text: 'x' }, () => {});
51 internals
.getRoot().browserAction
.setBadgeText({ text: '' }, () => {});
52 internals
.setIcon('call');
53 internals
.currentUrl
= null;
54 internals
.port
= null;
55 internals
.getRoot().browserAction
.enable();
58 async
joinAudioCall() {
60 internals
.getRoot().browserAction
.disable();
61 const activeTabs
= await internals
.getActiveTabs();
63 internals
.currentUrl
= activeTabs
[0].url
;
64 const execution
= await internals
.getRoot().tabs
.executeScript(activeTabs
[0].id
, {
65 file: '/build/content_script.js'
68 if (internals
.getRoot().runtime
.lastError
) {
69 internals
.onDisconnect();
73 if (execution
&& !execution
[0]) {
74 internals
.onDisconnect();
81 internals
.getRoot().browserAction
.disable();
82 internals
.port
.postMessage({
89 return !!(internals
.port
);
94 internals
.getRoot().browserAction
.setIcon({
95 path: internals
.icons
[iconSet
]
101 return window
.browser
|| window
.chrome
;
104 // Chrome doesn't yet implement the promise based tabs.query :'(
113 if (internals
.promisesSupported
) {
114 return internals
.getRoot().tabs
.query(query
);
117 return new Promise((resolve
) => {
119 internals
.getRoot().tabs
.query(query
, (tabs
) => {
121 return resolve(tabs
);
127 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);
128 internals
.getRoot().runtime
.onConnect
.addListener(internals
.onConnect
);