aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/help.ts
blob: 67296473f30064f6f93fb3e316751f2b8823c74f (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
45
46
47
48
49
50
51
52
import { localizeHtmlPage } from "../maze-utils/src/setup";
import Config from "./config";
import { showDonationLink } from "./utils/configUtils";

import { waitFor } from "../maze-utils/src";
import { isDeArrowInstalled } from "./utils/crossExtension";

if (document.readyState === "complete") {
    init();
} else {
    document.addEventListener("DOMContentLoaded", init);
}

// DeArrow promotion
waitFor(() => Config.isReady()).then(() => {
    if (Config.config.showNewFeaturePopups && Config.config.showUpsells) {
        isDeArrowInstalled().then((installed) => {
            if (!installed) {
                const deArrowPromotion = document.getElementById("dearrow-link");
                deArrowPromotion.classList.remove("hidden");

                deArrowPromotion.addEventListener("click", () => Config.config.showDeArrowPromotion = false);

                const text = deArrowPromotion.querySelector("#dearrow-link-text");
                text.textContent = `${chrome.i18n.getMessage("DeArrowPromotionMessage2").split("?")[0]}? ${chrome.i18n.getMessage("DeArrowPromotionMessage3")}`;

                const closeButton = deArrowPromotion.querySelector(".close-button");
                closeButton.addEventListener("click", (e) => {
                    e.preventDefault();

                    deArrowPromotion.classList.add("hidden");
                    Config.config.showDeArrowPromotion = false;
                    Config.config.showDeArrowInSettings = false;
                });
            }
        });
    }
});

async function init() {
    localizeHtmlPage();

    await waitFor(() => Config.config !== null);

    if (!Config.config.darkMode) {
        document.documentElement.setAttribute("data-theme", "light");
    }

    if (!showDonationLink()) {
        document.getElementById("sbDonate").style.display = "none";
    }
}