/
multithreading.js
29 lines (23 loc) · 1.02 KB
/
multithreading.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// require('dotenv').config();
// Replace this import with `require('..')` if you are running the example from the repository:
const { plugin } = require('puppeteer-with-fingerprints');
const key = process.env.FINGERPRINT_KEY ?? '';
async function main() {
const fingerprint = await plugin.fetch(key, { tags: ['Microsoft Windows', 'Chrome'] });
const browser = await plugin.useFingerprint(fingerprint).launch();
const page = await browser.newPage();
const getText = (selector) => page.$eval(selector, (el) => el.innerText);
await page.goto('https://browserleaks.com/javascript', { waitUntil: 'domcontentloaded' });
const result = {
screen: {
width: await getText('#js-innerWidth'),
height: await getText('#js-innerHeight'),
},
userAgent: await getText('#js-userAgent'),
deviceMemory: await getText('#js-deviceMemory'),
hardwareConcurrency: await getText('#js-hardwareConcurrency'),
};
await browser.close();
return result;
}
Promise.all([...Array(3).keys()].map(main)).then(console.log);