feat: detect headless browsers via missing headers (Playwright/Puppeteer)#8
Merged
feat: detect headless browsers via missing headers (Playwright/Puppeteer)#8
Conversation
…ders Adds detectHeadless(req) that scores browser-like requests on 6 signals: - Missing Accept-Language (every real browser sends this) - Missing Sec-Fetch-Mode (all modern browsers) - Missing Sec-CH-UA (Chromium 89+) - Sec-CH-UA contains HeadlessChrome - Missing or bare Accept header - Connection: close (browsers use keep-alive) Score >= 2 with a browser UA = headless-likely. Integration: - classifyRequest(req) promotes browser to headless-likely when detected - trackVisit emits headless_score and headless_likely properties - skipBrowsers: true now captures headless-likely requests (Aider, OpenCode) New exports: detectHeadless, classifyRequest, HeadlessDetection Bumps to v0.7.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detects Playwright-based agents (Aider, OpenCode) that spoof real browser UAs by checking for missing standard headers.
How it works
detectHeadless(req)scores browser-like requests on 6 signals:Accept-LanguageSec-Fetch-ModeSec-CH-UASec-CH-UAcontainsHeadlessChromeAcceptConnection: closeScore >= 2 with a browser UA =
headless-likely.Integration
classifyRequest(req)promotesbrowsertoheadless-likelywhen detectedtrackVisitemitsheadless_scoreandheadless_likelypropertiesskipBrowsers: truenow captures headless-likely requests alongside declared bots and HTTP clientsNew exports
detectHeadless(req)— standalone headless detectionclassifyRequest(req)— full request classification (UA + headers)HeadlessDetectiontypeBumps to v0.7.0. 103 tests pass.