-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Describe the feature
I were thinking of adding a attachFingerprintWithCDP method which would use objects provided by chrome-remote-interface. This way the suite could be easily usable with raw chrome implementations avoiding puppeteer/playwright
Motivation
I am using a custom chrome setup with raw CDP protocol and would like to swap my custom evasions with fingerprint-suite
Constraints
Not really, it seems fairly straightforward. The only global change would be in adding following packages to devDependencies:
"@types/chrome-remote-interface": "^0.33.3"
The idea is to add a method looking approximately like that:
import CDP from "@types/chrome-remote-interface";
async attachFingerprintToCDP(
page: CDP.StableDomains["Page"],
network: CDP.StableDomains["Network"],
emulation: CDP.StableDomains["Emulation"]
browserFingerprintWithHeaders: BrowserFingerprintWithHeaders,
): Promise<void> {
...
await network.setUserAgentOverride(userAgent);
....
await network.setExtraHTTPHeaders(
this.onlyInjectableHeaders(headers, browserVersion)
);
...
await emulation.emulateMediaFeatures(
[{ name: 'prefers-color-scheme', value: 'dark' }]
);
await page.addScriptToEvaluateOnNewDocument(
this.getInjectableFingerprintFunction(enhancedFingerprint)
);
}
Basically puppeteer does exactly the same using the chain of methods:
https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/cdp/EmulationManager.ts#L433
https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/cdp/NetworkManager.ts#L164
https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/cdp/FrameManager.ts#L284
Coulda make a PR for that if above would make sense