Skip to content

Commit

Permalink
feat: helpers accept raw fingerprints (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin authored Apr 24, 2023
1 parent a27ccd6 commit 131b762
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/fingerprint-injector/src/fingerprint-injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,13 @@ export class FingerprintInjector {
export async function newInjectedContext(
browser: PWBrowser,
options? : {
fingerprint?: BrowserFingerprintWithHeaders;
fingerprintOptions?: Partial<FingerprintGeneratorOptions>;
newContextOptions?: BrowserContextOptions;
},
): Promise<BrowserContext> {
const generator = new FingerprintGenerator();
const fingerprintWithHeaders = generator.getFingerprint(options?.fingerprintOptions ?? {});
const fingerprintWithHeaders = options?.fingerprint ?? generator.getFingerprint(options?.fingerprintOptions ?? {});

const { fingerprint, headers } = fingerprintWithHeaders;
const context = await browser.newContext({
Expand All @@ -303,11 +304,12 @@ export async function newInjectedContext(
export async function newInjectedPage(
browser: PPBrowser,
options? : {
fingerprint?: BrowserFingerprintWithHeaders;
fingerprintOptions?: Partial<FingerprintGeneratorOptions>;
},
): Promise<Page> {
const generator = new FingerprintGenerator();
const fingerprintWithHeaders = generator.getFingerprint(options?.fingerprintOptions ?? {});
const fingerprintWithHeaders = options?.fingerprint ?? generator.getFingerprint(options?.fingerprintOptions ?? {});

const page = await browser.newPage();

Expand Down

0 comments on commit 131b762

Please sign in to comment.