Skip to content

Use dynamic user agent instead of hardcoded Chrome version#28

Open
pirate wants to merge 1 commit into
mainfrom
claude/chrome-user-agent-audit-vRUwI
Open

Use dynamic user agent instead of hardcoded Chrome version#28
pirate wants to merge 1 commit into
mainfrom
claude/chrome-user-agent-audit-vRUwI

Conversation

@pirate
Copy link
Copy Markdown
Member

@pirate pirate commented May 22, 2026

Summary

Replace hardcoded user agent strings with dynamically generated ones derived from the actual browser instance. This prevents the user agent from becoming stale when the browser version is upgraded.

Key Changes

  • Modified three test files to generate realistic user agents dynamically instead of using a hardcoded Chrome 120.0.0.0 string:
    • abx_plugins/plugins/modalcloser/tests/test_modalcloser.py
    • abx_plugins/plugins/istilldontcareaboutcookies/tests/test_istilldontcareaboutcookies.py
    • abx_plugins/plugins/ublock/tests/test_ublock.py

Implementation Details

  • Retrieve the browser's default user agent using browser.userAgent()
  • Transform it to appear non-headless by:
    • Replacing 'HeadlessChrome/' with 'Chrome/'
    • Removing the ' Headless' suffix
  • This approach bypasses headless detection while remaining version-agnostic, eliminating the need to update hardcoded version strings during browser upgrades

https://claude.ai/code/session_01Qrpaidw2umKZjG5zGQZrkv


Summary by cubic

Use a dynamic user agent in test fixtures instead of a hardcoded Chrome/120 string to avoid stale UAs after browser upgrades and keep the headless-bypass working. We read browser.userAgent(), replace HeadlessChrome/ with Chrome/, remove the Headless suffix, then call page.setUserAgent() in tests for modalcloser, istilldontcareaboutcookies, and ublock.

Written for commit c281077. Summary will update on new commits. Review in cubic

The headless-detection-bypass UA in ublock/modalcloser/istilldontcareaboutcookies
tests was a literal Chrome/120.0.0.0 string, so the fixtures aged with every
Chrome upgrade and risked drifting noticeably from the real browser's UA.

Read the actual UA via browser.userAgent() and strip the "Headless" /
"HeadlessChrome" tokens — same fingerprint-evasion effect, no baked-in
version to keep up to date.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

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.

2 participants