-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (17 loc) · 745 Bytes
/
index.js
File metadata and controls
25 lines (17 loc) · 745 Bytes
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
const puppeteer = require('puppeteer');
const applyEvasions = require('./apply-evasions');
const detectHeadless = require('./detect-headless');
async function run({includeEvasions = true, suppressLogs = false}) {
const browser = await puppeteer.launch({args: ['--no-sandbox']});
const page = await browser.newPage();
page.on('console', msg => {
if (!suppressLogs) console.log('Page console: ', msg.text());
});
if (includeEvasions) await applyEvasions(page);
await page.goto('about:blank');
const detectionResults = await page.evaluate(detectHeadless);
console.assert(Object.keys(detectionResults).length, 'No detection results returned.');
await browser.close();
return detectionResults;
}
module.exports = run;