blob: 5b9cb498fa0b7dc527db4b7d9e0b8e81b7152316 (
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 "@ajayyy/maze-utils/lib/config";
import { isFirefoxOrSafari } from "@ajayyy/maze-utils";
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;
}
}
|