Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Remove Headless from user agent in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Nov 12, 2024
1 parent a5ba0c4 commit ecc2011
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,19 @@ func (b *Browser) fetchVersion() (browserVersion, error) {
return browserVersion{}, fmt.Errorf("getting browser version information: %w", err)
}

// Adjust to user agent to remove the headless part.
//
// Including Headless might cause issues with some websites that treat headless
// browsers differently. Later on, [BrowserContext] will set the user agent to
// this user agent if not set by the user. This will force [FrameSession] to
// set the user agent to the browser's user agent.
//
// Doing this here provides a consistent user agent across all browser contexts.
// Also, it makes it consistent to query the user agent from the browser.
if b.browserOpts.Headless {
bv.userAgent = strings.ReplaceAll(bv.userAgent, "Headless", "")
}

return bv, nil
}

Expand Down

0 comments on commit ecc2011

Please sign in to comment.