Skip to content

Add promotional banner for iframe-embedded games#144

Merged
Hugo0 merged 4 commits intomainfrom
feature/iframe-embed-banner
Mar 14, 2026
Merged

Add promotional banner for iframe-embedded games#144
Hugo0 merged 4 commits intomainfrom
feature/iframe-embed-banner

Conversation

@Hugo0
Copy link
Owner

@Hugo0 Hugo0 commented Mar 14, 2026

Summary

  • Detects when the game is loaded inside an iframe on third-party sites (e.g., wordlespielen.de, sanuliwordle.fi)
  • Shows a subtle "Play Wordle in 65+ languages" banner after game win (2s delay) or loss (3s delay)
  • Links to wordle.global/{lang} in a new tab, converting iframe users into direct visitors
  • 30-day dismiss cooldown via localStorage
  • Replaces the PWA install prompt when embedded (which doesn't work in cross-origin iframes anyway)

Why

At least 5 sites are iframing wordle.global without attribution. Google doesn't credit iframes as backlinks, so we get zero SEO benefit. This banner promotes our brand directly to those users and drives organic traffic back to us.

Files changed

  • frontend/src/embed.ts — New module: iframe detection, banner show/hide/dismiss logic
  • frontend/src/game.ts — Show embed banner instead of PWA banner when in iframe
  • frontend/src/main.ts — Expose dismissEmbedBanner to window
  • frontend/src/style.css — Banner styling (fixed bottom, green gradient)
  • webapp/templates/game.html — Banner HTML

Test plan

  • Play a game on wordle.global directly — should NOT see embed banner, should still see PWA prompt
  • Load wordle.global/fi in an iframe on another page — after win/loss, embed banner should appear
  • Click "Visit" — should open wordle.global/fi in new tab
  • Click × to dismiss — banner should not reappear for 30 days
  • Verify build passes (pnpm build, pnpm test)

Summary by CodeRabbit

Release Notes

  • New Features
    • Added an embed banner that appears when the game is played on external websites, featuring a link to visit the main Wordle site in your language
    • Banner includes a dismiss option that persists for 30 days

When the game is loaded inside an iframe (e.g., wordlespielen.de embedding /de),
show a subtle bottom banner after game completion that links to wordle.global.
The banner has a 30-day dismiss cooldown and does not show for direct visitors
or standalone PWA users.
@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Warning

Rate limit exceeded

@Hugo0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aad7579c-addc-445a-8092-52ebc9b8cd0a

📥 Commits

Reviewing files that changed from the base of the PR and between 10345aa and cb6757d.

📒 Files selected for processing (3)
  • frontend/src/embed.ts
  • frontend/src/game.ts
  • frontend/src/style.css
📝 Walkthrough

Walkthrough

A new embed banner feature is introduced to detect when the game runs inside an iframe, conditionally display a banner after game completion, persist dismissal state via localStorage for 30 days, and expose the dismissal functionality through the global window interface and frontend module.

Changes

Cohort / File(s) Summary
Embed Banner Module
frontend/src/embed.ts
Adds iframe detection, banner visibility management, and dismissal persistence. Provides isEmbedded(), showBanner(), hideBanner(), dismiss() functions, and a default embed export with cross-origin and private-browsing localStorage error handling.
Game Flow Integration
frontend/src/game.ts
Imports embed module and conditionally displays banner after game completion (2 seconds on win, 3 seconds on loss) based on iframe detection status.
Global API Exposure
frontend/src/main.ts
Extends Window interface with dismissEmbedBanner() function and wires it to the embed module's dismiss method for UI integration.
Styling
frontend/src/style.css
Adds fixed-position embed-banner CSS with gradient background, white text, dismiss button styling, and high z-index for visibility.
Template Structure
webapp/templates/game.html
Adds hidden embed-banner div element in two locations with title, visit link, and dismiss button wired to dismissEmbedBanner().

Sequence Diagram(s)

sequenceDiagram
    participant Game as Game Logic
    participant Embed as Embed Module
    participant DOM as DOM
    participant Storage as localStorage

    Game->>Embed: isEmbedded()?
    Embed->>Embed: Check window.self !== window.top
    Embed-->>Game: true/false

    alt Game Won/Lost
        Game->>Embed: showBanner()
        Embed->>DOM: Display embed-banner
        Note over DOM: Banner visible to user
        
        DOM->>DOM: User clicks dismiss
        DOM->>Embed: dismiss()
        Embed->>Storage: Set dismissal state + timestamp
        Embed->>DOM: Hide banner
    else User Refreshes/Revisits
        Embed->>Storage: Check dismissal timestamp
        Storage-->>Embed: Timestamp (if within 30 days)
        alt Within 30-day window
            Embed->>DOM: Keep banner hidden
        else Expired
            Embed->>DOM: Allow banner to show
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop, hop! A banner now appears,
When games in iframes are near,
Embed detection, dismiss with cheer,
Thirty days of peace, no fear! 🎮

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add promotional banner for iframe-embedded games' accurately and concisely summarizes the main change: introducing a banner for games running in iframes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/iframe-embed-banner
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
webapp/templates/game.html (1)

654-656: Consider localizing the banner text for consistency.

The text "Play Wordle in 65+ languages" is hardcoded in English, while other UI strings use localized values from language.config.ui. Consider using a pattern like:

<strong>{{ language.config.ui.play_in_languages or "Play Wordle in 65+ languages" }}</strong>

This maintains English as a fallback while allowing localization for languages that provide translations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webapp/templates/game.html` around lines 654 - 656, Replace the hardcoded
banner text with a localized UI value so translations can override it: find the
strong tag rendering "Play Wordle in 65+ languages" and use the template
variable language.config.ui.play_in_languages with an English fallback (e.g.
"Play Wordle in 65+ languages") so the banner pulls from the same localization
source as other UI strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@webapp/templates/game.html`:
- Around line 652-662: The anchor in the embed banner uses a nonexistent
attribute language.code causing a broken link; update the href to use the
correct attribute language.language_code (i.e., change "{{ language.code }}" to
"{{ language.language_code }}") so the Visit link points to the proper URL;
ensure any other occurrences within the embed banner (e.g., text or JS
interactions referencing language.code) are also updated to
language.language_code and keep the existing rel/target attributes and
dismissEmbedBanner() button unchanged.

---

Nitpick comments:
In `@webapp/templates/game.html`:
- Around line 654-656: Replace the hardcoded banner text with a localized UI
value so translations can override it: find the strong tag rendering "Play
Wordle in 65+ languages" and use the template variable
language.config.ui.play_in_languages with an English fallback (e.g. "Play Wordle
in 65+ languages") so the banner pulls from the same localization source as
other UI strings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 76d5589b-ff56-4da5-b705-1657dcccb50b

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3d046 and 10345aa.

📒 Files selected for processing (5)
  • frontend/src/embed.ts
  • frontend/src/game.ts
  • frontend/src/main.ts
  • frontend/src/style.css
  • webapp/templates/game.html

Comment on lines +652 to +662
<!-- Embed banner for iframe embeds -->
<div id="embed-banner" class="embed-banner" style="display: none;">
<div style="flex: 1;">
<strong>Play Wordle in 65+ languages</strong>
</div>
<a href="https://wordle.global/{{ language.code }}" target="_blank" rel="noopener"
style="background: white; color: #2d6a4f; border: none; padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform 0.1s;">
Visit
</a>
<button class="dismiss" onclick="dismissEmbedBanner()">&times;</button>
</div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: language.code attribute does not exist — link will be broken.

The Language class defines self.language_code (see webapp/app.py line 647), not self.code. This will cause the "Visit" link to render incorrectly (empty or error).

Compare with line 2 of this template which correctly uses language.language_code, and lines 49/55/59/71/87 which use language.config.language_code.

🐛 Proposed fix
-        <a href="https://wordle.global/{{ language.code }}" target="_blank" rel="noopener"
+        <a href="https://wordle.global/{{ language.language_code }}" target="_blank" rel="noopener"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webapp/templates/game.html` around lines 652 - 662, The anchor in the embed
banner uses a nonexistent attribute language.code causing a broken link; update
the href to use the correct attribute language.language_code (i.e., change "{{
language.code }}" to "{{ language.language_code }}") so the Visit link points to
the proper URL; ensure any other occurrences within the embed banner (e.g., text
or JS interactions referencing language.code) are also updated to
language.language_code and keep the existing rel/target attributes and
dismissEmbedBanner() button unchanged.

Hugo0 added 3 commits March 14, 2026 14:26
- Cache isEmbedded as a const (never changes during session)
- Lazy-evaluate isDismissed() only when showing banner (avoid
  localStorage read for non-embedded users)
- Remove redundant isEmbedded() checks in game.ts callers — let
  showBanner() own its own guard logic
- Call both embed.showBanner() and pwa.showBanner() unconditionally
  (each no-ops when not applicable), fixing gameLost inconsistency
- Extract shared .bottom-banner CSS base class to deduplicate styles
- Move embed banner inline styles to CSS classes
@Hugo0 Hugo0 merged commit 78d7a60 into main Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant