diff --git a/src/client/DesktopShell.ts b/src/client/DesktopShell.ts new file mode 100644 index 000000000..3c6da51ba --- /dev/null +++ b/src/client/DesktopShell.ts @@ -0,0 +1,13 @@ +// The Electron desktop (Steam) shell exposes this global via a contextBridge +// preload script — see openfront-desktop's src/preload/preload.ts. Its mere +// presence is a reliable signal we're running inside that shell, since only +// the desktop build's preload script ever sets it. +declare global { + interface Window { + openfrontDesktop?: unknown; + } +} + +export function isDesktopShell(): boolean { + return typeof window !== "undefined" && window.openfrontDesktop !== undefined; +} diff --git a/src/client/Main.ts b/src/client/Main.ts index 39e609c8e..dc40cc090 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -26,6 +26,7 @@ import "./CosmeticsModal"; import { CosmeticsModal } from "./CosmeticsModal"; import { updateCrazyGamesNavButton } from "./CrazyGamesAccountButton"; import { crazyGamesSDK } from "./CrazyGamesSDK"; +import { isDesktopShell } from "./DesktopShell"; import "./FeaturedStream"; import "./FlagInput"; import { FlagInput } from "./FlagInput"; @@ -505,7 +506,8 @@ class Client { } const isAdFree = userMeResponse !== false && userMeResponse.player?.adfree === true; - window.adsEnabled = !isAdFree && !crazyGamesSDK.isOnCrazyGames(); + window.adsEnabled = + !isAdFree && !crazyGamesSDK.isOnCrazyGames() && !isDesktopShell(); // Ad-eligible users only: paid/adfree users must never load Admiral (its // adblock popup fires autonomously once the payload runs). Start watching // adblock state; once a blocker is ever detected the in-game ad is