Skip to content

override user agent metadata and other fixes#29

Open
iloveitaly wants to merge 11 commits intoAtuboDad:mainfrom
iloveitaly:user-agent-fix
Open

override user agent metadata and other fixes#29
iloveitaly wants to merge 11 commits intoAtuboDad:mainfrom
iloveitaly:user-agent-fix

Conversation

@iloveitaly
Copy link

This PR contains improvements from this branch in addition
to further improvements necessary to mock out the navigator.userAgentData object which was causing bot detection failures
in my case.

I've also made some slight improvements to the loading code to make it less repetitive.

I have some additional improvements locally that enable us to more easily determine possible differences betweeen headless & headful mode that I'd like to submit in a separate PR

paveldudka and others added 11 commits March 6, 2024 18:48
Updated goto link
Replaced asyncio.eventloop() to asyncio.run()
Added stealth arguments
Added full page screenshot for stealth with passed arguments with desired value
*in this case: mimicking a mobile device*
support msedge (HeadlessEdg/)
Remove deprecated pkg_resources references
log not exist
replace all 'Headless'
del all 'Headless'
@tobwen
Copy link

tobwen commented Aug 9, 2024

Good work! It worked for all but Webkit - but only for playwright==1.43.0

playwright==1.43.0

chromium

image

firefox

image

webkit

image

playwright>1.43.0

On latest playwright, it fails:

chromium

image

firefox

image

@Mattwmaster58
Copy link
Contributor

@tobwen could the failures be related to #31 ?

const current_ua = navigator.userAgent
Object.defineProperty(Object.getPrototypeOf(navigator), 'userAgent', {
get: () => opts.navigator_user_agent || current_ua.replace('HeadlessChrome/', 'Chrome/')
get: () => opts.navigator_user_agent || current_ua.replace(/Headless/g, '')

Choose a reason for hiding this comment

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

There is no check if opts is undefined (also in the original code, yes). This will break scripts on other websites that rely on navigator.userAgent

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.

7 participants