From 4d5b7c0fb678fb29cd74facd5a153e4e1c1ce9ca Mon Sep 17 00:00:00 2001 From: evanpelle Date: Fri, 1 May 2026 18:39:11 -0600 Subject: [PATCH] Use adfree flag to suppress ads Adds adfree: boolean to player in UserMeResponseSchema and replaces the flares-length heuristic in Main.ts with a direct check of this field to determine whether ads should be shown. --- src/client/Main.ts | 8 +++----- src/core/ApiSchemas.ts | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/Main.ts b/src/client/Main.ts index bae704ac5..cb009ba9d 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -438,11 +438,9 @@ class Client { const onUserMe = async (userMeResponse: UserMeResponse | false) => { updateAccountNavButton(userMeResponse); - const hasLinkedAccount = - !crazyGamesSDK.isOnCrazyGames() && - ((userMeResponse || null)?.player?.flares?.length ?? 0) > 0; - console.log("ads enabled: ", hasLinkedAccount); - window.adsEnabled = !hasLinkedAccount && !crazyGamesSDK.isOnCrazyGames(); + const isAdFree = + userMeResponse !== false && userMeResponse.player?.adfree === true; + window.adsEnabled = !isAdFree && !crazyGamesSDK.isOnCrazyGames(); document.dispatchEvent( new CustomEvent("userMeResponse", { detail: userMeResponse, diff --git a/src/core/ApiSchemas.ts b/src/core/ApiSchemas.ts index 859cdeb58..f7ae878f6 100644 --- a/src/core/ApiSchemas.ts +++ b/src/core/ApiSchemas.ts @@ -77,6 +77,7 @@ export const UserMeResponseSchema = z.object({ }), player: z.object({ publicId: z.string(), + adfree: z.boolean(), flares: z.string().array().optional(), achievements: z.object({ singleplayerMap: z.array(SingleplayerMapAchievementSchema),