]>
git.r.bdr.sh - rbdr/junction/blob - extension/junction.js
776096927473e635738e8577f8988675b7e9645e
2 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
.initializeContentScript();
28 internals
.port
.postMessage({
29 action: "joinAudioCall",
31 currentUrl: internals
.currentUrl
,
32 tada: internals
.getRoot().runtime
.getURL("sounds/tada.wav"),
35 internals
.getRoot().browserAction
.enable();
36 internals
.setIcon("hangUp");
40 internals
.port
= port
;
41 port
.onDisconnect
.addListener(internals
.onDisconnect
);
42 port
.onMessage
.addListener(internals
.onMessage
);
43 internals
.joinAudioCall();
47 if (message
.action
=== "error") {
48 internals
.getRoot().browserAction
.setBadgeText({ text: "x" }, () => {});
53 internals
.getRoot().browserAction
.setBadgeText({ text: "" }, () => {});
54 internals
.setIcon("call");
55 internals
.currentUrl
= null;
56 internals
.port
= null;
57 internals
.getRoot().browserAction
.enable();
60 async
initializeContentScript() {
61 internals
.getRoot().browserAction
.disable();
62 const activeTabs
= await internals
.getActiveTabs();
64 internals
.currentUrl
= activeTabs
[0].url
;
65 if (!internals
.injectedScript
) {
66 const execution
= await internals
.getRoot().tabs
.executeScript(
69 file: "/build/content_script.js",
72 internals
.injectedScript
= true;
76 internals
.getRoot().tabs
.connect(activeTabs
[0].id
)
79 if (execution
&& !execution
[0]) {
80 internals
.onDisconnect();
84 internals
.getRoot().browserAction
.disable();
85 internals
.port
.postMessage({
91 return !!internals
.port
;
95 internals
.getRoot().browserAction
.setIcon({
96 path: internals
.icons
[iconSet
],
101 return window
.browser
|| window
.chrome
;
104 // Chrome doesn't yet implement the promise based tabs.query :'(
112 if (internals
.promisesSupported
) {
113 return internals
.getRoot().tabs
.query(query
);
116 return new Promise((resolve
) => {
117 internals
.getRoot().tabs
.query(query
, (tabs
) => {
118 return resolve(tabs
);
124 internals
.getRoot().browserAction
.onClicked
.addListener(internals
.onClick
);
125 internals
.getRoot().runtime
.onConnect
.addListener(internals
.onConnect
);