Skip to content

Exempt the Electron desktop shell from loading Admiral ads - #4651

Merged
evanpelle merged 3 commits into
mainfrom
desktop/exempt-electron-from-ads
Jul 22, 2026
Merged

Exempt the Electron desktop shell from loading Admiral ads#4651
evanpelle merged 3 commits into
mainfrom
desktop/exempt-electron-from-ads

Conversation

@Celant

@Celant Celant commented Jul 20, 2026

Copy link
Copy Markdown
Member

Add approved & assigned issue number here:

Description:

Admiral (src/client/Admiral.ts), OpenFront's ad-recovery vendor, is injected via a runtime document.createElement("script") call rather than a static HTML <script> tag. That makes it invisible to HTML-level ad stripping done in the (private, separate) Electron/Steam shell repo, so it was attempting to load — and cascading into further ad-exchange calls — inside the paid desktop client.

Main.ts already exempts CrazyGames-hosted sessions from Admiral via window.adsEnabled = !isAdFree && !crazyGamesSDK.isOnCrazyGames(). This extends that same, existing gate to also cover the Electron desktop shell, detected via a new src/client/DesktopShell.ts (isDesktopShell()), which mirrors CrazyGamesSDK.ts's isOnCrazyGames() pattern: it checks for window.openfrontDesktop, a global only the Electron app's own preload script ever sets. No behavior change for web/CrazyGames users — the change is a single additional && clause.

Please complete the following:

  • I have added screenshots for all UI updates — n/a, no UI change
  • I process any text displayed to the user through translateText() and I've added it to the en.json file — n/a, no user-facing text added
  • I have added relevant tests to the test directory — no unit test added; following existing convention in this area (CrazyGamesSDK.ts's isOnCrazyGames(), the pattern this mirrors, also has no dedicated unit test). Verified instead via tsc --noEmit, eslint/prettier, a full build-prod, and the Electron shell's own e2e network-isolation test confirming Admiral's script (and downstream ad-exchange calls) no longer attempt to load when window.openfrontDesktop is present.

Please put your Discord username so you can be contacted if a bug or regression is found:

jish

Admiral (introjava.com) is injected via a runtime document.createElement
call, not a static <script> tag, so it's invisible to any HTML-level
stripping done downstream in the Electron/Steam build. Extend the existing
adsEnabled gate (which already exempts CrazyGames) to also exempt the
desktop shell, detected via the window.openfrontDesktop global its preload
script exposes.

Discovered via openfront-desktop's offline-network e2e test, which caught
real requests to introjava.com and aax.amazon-adsystem.com during an
offline app load.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f637fb49-8a7f-4af2-8227-4c1f7b815ccd

📥 Commits

Reviewing files that changed from the base of the PR and between 37e5b1b and ca9ea00.

📒 Files selected for processing (1)
  • src/client/Main.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/client/Main.ts

Walkthrough

Adds Electron desktop-shell detection and disables ads when the application runs inside that shell.

Changes

Desktop shell ad handling

Layer / File(s) Summary
Desktop detection and ad gating
src/client/DesktopShell.ts, src/client/Main.ts
Declares the desktop preload global, exports isDesktopShell(), and requires the runtime to be outside the desktop shell before enabling ads.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A desktop shell now marks its place,
Ads step back with quiet grace.
A preload sign, a simple check,
Keeps the ad flow on the right deck.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: blocking Admiral ads in the Electron desktop shell.
Description check ✅ Passed The description is directly related to the code changes and explains the desktop-shell ad exemption clearly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Celant Celant added this to the Backlog milestone Jul 20, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 20, 2026
@iiamlewis

Copy link
Copy Markdown
Contributor

Yes

@iiamlewis
iiamlewis enabled auto-merge July 22, 2026 12:04
@iiamlewis
iiamlewis added this pull request to the merge queue Jul 22, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Final Review in OpenFront Release Management Jul 22, 2026
@evanpelle
evanpelle removed this pull request from the merge queue due to a manual request Jul 22, 2026
@evanpelle
evanpelle merged commit 3e2251b into main Jul 22, 2026
12 checks passed
@evanpelle
evanpelle deleted the desktop/exempt-electron-from-ads branch July 22, 2026 20:08
@github-project-automation github-project-automation Bot moved this from Final Review to Complete in OpenFront Release Management Jul 22, 2026
evanpelle pushed a commit that referenced this pull request Jul 25, 2026
**Add approved & assigned issue number here:**

## Description:

Admiral (`src/client/Admiral.ts`), OpenFront's ad-recovery vendor, is
injected via a runtime `document.createElement("script")` call rather
than a static HTML `<script>` tag. That makes it invisible to HTML-level
ad stripping done in the (private, separate) Electron/Steam shell repo,
so it was attempting to load — and cascading into further ad-exchange
calls — inside the paid desktop client.

`Main.ts` already exempts CrazyGames-hosted sessions from Admiral via
`window.adsEnabled = !isAdFree && !crazyGamesSDK.isOnCrazyGames()`. This
extends that same, existing gate to also cover the Electron desktop
shell, detected via a new `src/client/DesktopShell.ts`
(`isDesktopShell()`), which mirrors `CrazyGamesSDK.ts`'s
`isOnCrazyGames()` pattern: it checks for `window.openfrontDesktop`, a
global only the Electron app's own preload script ever sets. No behavior
change for web/CrazyGames users — the change is a single additional `&&`
clause.

## Please complete the following:

- [x] I have added screenshots for all UI updates — n/a, no UI change
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file — n/a, no user-facing text added
- [ ] I have added relevant tests to the test directory — no unit test
added; following existing convention in this area (`CrazyGamesSDK.ts`'s
`isOnCrazyGames()`, the pattern this mirrors, also has no dedicated unit
test). Verified instead via `tsc --noEmit`, `eslint`/`prettier`, a full
`build-prod`, and the Electron shell's own e2e network-isolation test
confirming Admiral's script (and downstream ad-exchange calls) no longer
attempt to load when `window.openfrontDesktop` is present.

## Please put your Discord username so you can be contacted if a bug or
regression is found:

jish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants