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.
This commit is contained in:
evanpelle
2026-05-01 18:39:11 -06:00
parent 914c7e750f
commit 4d5b7c0fb6
2 changed files with 4 additions and 5 deletions
+3 -5
View File
@@ -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,
+1
View File
@@ -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),