If you're building a Chrome extension that works with AI chat platforms — prompt injection, session export, UI customization — you need to know which platform the user is on before you do anything. A content script that injects a prompt into ChatGPT's textarea will silently fail on Claude, which has a completely different DOM.

Here's how to reliably detect the platform from a content script, with patterns that hold up through UI redesigns.

Matching by URL (Tier 1: Fast and Reliable)

The fastest check: location.hostname. AI platforms use distinct domains with predictable structures:

const AI_PLATFORM_HOSTS = {