blob: 183ae931626dad3c52ecb1b62cf8795f1e63b8b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import * as CompileConfig from "../../config.json";
import Config from "../config";
import { isSafari } from "../../maze-utils/src/config";
import { isFirefoxOrSafari } from "../../maze-utils/src";
export function isDeArrowInstalled(): Promise<boolean> {
if (Config.config.deArrowInstalled) {
return Promise.resolve(true);
} else {
return new Promise((resolve) => {
const extensionIds = getExtensionIdsToImportFrom();
let count = 0;
for (const id of extensionIds) {
chrome.runtime.sendMessage(id, { message: "isInstalled" }, (response) => {
if (chrome.runtime.lastError) {
count++;
if (count === extensionIds.length) {
resolve(false);
}
return;
}
resolve(response);
if (response) {
Config.config.deArrowInstalled = true;
}
});
}
});
}
}
export function getExtensionIdsToImportFrom(): string[] {
if (isSafari()) {
return CompileConfig.extensionImportList.safari;
} else if (isFirefoxOrSafari()) {
return CompileConfig.extensionImportList.firefox;
} else {
return CompileConfig.extensionImportList.chromium;
}
}
|