]>
git.r.bdr.sh - rbdr/junction/blob - extension/junction.js
3e8b4d9e4996b50c738d476df389573ad0e4d09d
2 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();
27 internals
.port
= port
;
28 port
.onDisconnect
.addListener(internals
.onDisconnect
);
29 port
.onMessage
.addListener(internals
.onMessage
);
31 action: "joinAudioCall",
33 currentUrl: internals
.currentUrl
,
34 tada: internals
.getRoot().runtime
.getURL("sounds/tada.wav"),
37 internals
.getRoot().browserAction
.enable();
38 internals
.setIcon("hangUp");
42 if (message
.action
=== "error") {
43 internals
.getRoot().browserAction
.setBadgeText({ text: "x" }, () => {});
48 internals
.getRoot().browserAction
.setBadgeText({ text: "" }, () => {});
49 internals
.setIcon("call");
50 internals
.currentUrl
= null;
51 internals
.port
= null;
52 internals
.getRoot().browserAction
.enable();
55 async
joinAudioCall() {
56 internals
.getRoot().browserAction
.disable();
57 const activeTabs
= await internals
.getActiveTabs();
59 internals
.currentUrl
= activeTabs
[0].url
;
60 const execution
= await internals
.getRoot().tabs
.executeScript(
63 file: "/build/content_script.js",
66 if (internals
.getRoot().runtime
.lastError
) {
67 internals
.onDisconnect();
72 if (execution
&& !execution
[0]) {
73 internals
.onDisconnect();
77 internals
.getRoot().browserAction
.disable();
78 internals
.port
.postMessage({
84 return !!internals
.port
;
88 internals
.getRoot().browserAction
.setIcon({
89 path: internals
.icons
[iconSet
],
94 return window
.browser
|| window
.chrome
;
97 // Chrome doesn't yet implement the promise based tabs.query :'(
105 if (internals
.promisesSupported
) {
106 return internals
.getRoot().tabs
.query(query
);
109 return new Promise((resolve
) => {
110 internals
.getRoot().tabs
.query(query
, (tabs
) => {
111 return resolve(tabs
);
117 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);
118 internals
.getRoot().runtime
.onConnect
.addListener(internals
.onConnect
);