Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased [patch]

> Development of this release was supported by [Reset Tech](https://www.reset.tech).

### Fixed

- Fix browser and request language with full DOM fetcher

## 10.3.0 - 2026-01-12

> Development of this release was made on a volunteer basis by [@Ndpnt](http://github.com/ndpnt).
Expand Down
16 changes: 14 additions & 2 deletions src/archivist/fetcher/fullDomFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import stealthPlugin from 'puppeteer-extra-plugin-stealth';

import { resolveProxyConfiguration, extractProxyCredentials } from './proxyUtils.js';

puppeteer.use(stealthPlugin());

let browser;

export default async function fetch(url, cssSelectors, config) {
puppeteer.use(stealthPlugin({ locale: config.language }));

let context;
let page;
let client;
let response;
const selectors = [].concat(cssSelectors);

Expand All @@ -25,6 +26,14 @@ export default async function fetch(url, cssSelectors, config) {
await page.setDefaultNavigationTimeout(config.navigationTimeout);
await page.setExtraHTTPHeaders({ 'Accept-Language': config.language });

// Use CDP to ensure the browser language is set correctly (most reliable method, see https://zirkelc.dev/posts/puppeteer-language-experiment)
client = await page.createCDPSession();

await client.send('Network.setUserAgentOverride', {
userAgent: await browser.userAgent(),
acceptLanguage: config.language,
});

if (browser.proxyCredentials?.username && browser.proxyCredentials?.password) {
await page.authenticate(browser.proxyCredentials);
}
Expand Down Expand Up @@ -73,6 +82,9 @@ export default async function fetch(url, cssSelectors, config) {
}
throw new Error(error.message);
} finally {
if (client) {
await client.detach();
}
if (page) {
await page.close();
}
Expand Down
Loading