diff --git a/frontend/src/ts/index.ts b/frontend/src/ts/index.ts index ea4b062af..d270391fd 100644 --- a/frontend/src/ts/index.ts +++ b/frontend/src/ts/index.ts @@ -31,6 +31,7 @@ import "./popups/edit-tags-popup"; import "./popups/google-sign-up-popup"; import * as Account from "./pages/account"; import "./elements/leaderboards"; +import { egVideoListener } from "./popups/video-ad-popup"; type ExtendedGlobal = typeof globalThis & MonkeyTypes.Global; @@ -55,3 +56,5 @@ extendedGlobal.getTimerStats = TestTimer.getTimerStats; extendedGlobal.toggleUnsmoothedRaw = Result.toggleUnsmoothedRaw; extendedGlobal.enableSpacingDebug = TestInput.enableSpacingDebug; + +extendedGlobal.egVideoListener = egVideoListener; diff --git a/frontend/src/ts/popups/video-ad-popup.ts b/frontend/src/ts/popups/video-ad-popup.ts index 777932b87..c2fd26454 100644 --- a/frontend/src/ts/popups/video-ad-popup.ts +++ b/frontend/src/ts/popups/video-ad-popup.ts @@ -1,3 +1,5 @@ +import * as Notifications from "../elements/notifications"; + function show(): void { if ($("#videoAdPopupWrapper").hasClass("hidden")) { $("#videoAdPopupWrapper") @@ -28,10 +30,19 @@ function hide(): void { } } +export function egVideoListener(options: Record): void { + const event = options["event"]; + + if (event === "started") { + // + } else if (event === "finished") { + hide(); + } else if (event === "empty") { + Notifications.add("Failed to load video ad. Please try again later", 0, 3); + hide(); + } +} + $(".pageTest #watchVideoAdButton").on("click", () => { show(); }); - -$("#videoAdPopup .button").on("click", () => { - hide(); -}); diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts index b2ea076db..79df91eba 100644 --- a/frontend/src/ts/types/types.d.ts +++ b/frontend/src/ts/types/types.d.ts @@ -583,6 +583,7 @@ declare namespace MonkeyTypes { toggleUnsmoothedRaw(): void; enableSpacingDebug(): void; noGoogleNoMo(): void; + egVideoListener(options: Record): void; } interface GithubRelease { diff --git a/frontend/static/html/popups.html b/frontend/static/html/popups.html index 5855f0e65..98c72ccc3 100644 --- a/frontend/static/html/popups.html +++ b/frontend/static/html/popups.html @@ -227,7 +227,6 @@
-
Click to close