diff options
author | Ajay <[email protected]> | 2023-11-07 20:49:25 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2023-11-07 20:49:25 -0500 |
commit | 14d50b9e70133bae0012a8d86da5b2e440fa0297 (patch) | |
tree | 22a9cded5f641360d7712782af0347c2174a0108 /src | |
parent | cfe314742dca3c8902ba8af12421354e1de30ce9 (diff) | |
download | SponsorBlock-14d50b9e70133bae0012a8d86da5b2e440fa0297.tar.gz SponsorBlock-14d50b9e70133bae0012a8d86da5b2e440fa0297.zip |
Add dearrow link to install page and add close button
Diffstat (limited to 'src')
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/help.ts | 27 | ||||
-rw-r--r-- | src/options.ts | 11 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/config.ts b/src/config.ts index e820160d..95a36421 100644 --- a/src/config.ts +++ b/src/config.ts @@ -75,6 +75,7 @@ interface SBConfig { allowScrollingToEdit: boolean; deArrowInstalled: boolean; showDeArrowPromotion: boolean; + showDeArrowInSettings: boolean; showZoomToFillError2: boolean; // Used to cache calculated text color info @@ -317,6 +318,7 @@ const syncDefaults = { allowScrollingToEdit: true, deArrowInstalled: false, showDeArrowPromotion: false, + showDeArrowInSettings: true, showZoomToFillError2: true, categoryPillColors: {}, diff --git a/src/help.ts b/src/help.ts index 3b8c636b..67296473 100644 --- a/src/help.ts +++ b/src/help.ts @@ -3,6 +3,7 @@ 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(); @@ -10,6 +11,32 @@ if (document.readyState === "complete") { 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(); diff --git a/src/options.ts b/src/options.ts index 965c9840..8acdd86e 100644 --- a/src/options.ts +++ b/src/options.ts @@ -74,13 +74,22 @@ async function init() { } // DeArrow promotion - if (Config.config.showNewFeaturePopups && Config.config.showUpsells) { + if (Config.config.showNewFeaturePopups && Config.config.showUpsells && Config.config.showDeArrowInSettings) { isDeArrowInstalled().then((installed) => { if (!installed) { const deArrowPromotion = document.getElementById("deArrowPromotion"); deArrowPromotion.classList.remove("hidden"); deArrowPromotion.addEventListener("click", () => Config.config.showDeArrowPromotion = false); + + const closeButton = deArrowPromotion.querySelector(".close-button"); + closeButton.addEventListener("click", (e) => { + e.preventDefault(); + + deArrowPromotion.classList.add("hidden"); + Config.config.showDeArrowPromotion = false; + Config.config.showDeArrowInSettings = false; + }); } }); } |