SIGN IN SIGN UP

fix: pass locale as argument to evaluateOnNewDocument (#1244)

The previous code passed a closure to page.evaluateOnNewDocument() that
referenced `options.locale` from the outer scope. However, Puppeteer
serialises the callback function and executes it in the browser page
context where the `options` variable does not exist. This caused
`navigator.language` and `navigator.languages` to silently return
`undefined` instead of the requested locale, which in turn could cause
locale-sensitive pages to behave unexpectedly (e.g. triggering CAPTCHAs,
rendering different content, or failing to load entirely).

Fix: pass `options.locale` as a serialisable argument to
`evaluateOnNewDocument(fn, ...args)` so the value is correctly
transferred to the page context.

Fixes #1236

Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com>
Co-authored-by: Yanlong Wang <yanlong.wang@naiver.org>
D
d 🔹 committed
f7c491b6e3bb533c0159deb367c62dc280791f35
Parent: 0612fa0
Committed by GitHub <noreply@github.com> on 4/16/2026, 6:37:01 AM