Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const snapThis = async () => {
console.log('Starting...');
const browser = await puppeteer.launch({ headless: true, ignoreHTTPSErrors: true });
console.log('Taking screenshots...');
for (let i = 0; i < devices.length; i++) {
process.stdout.write(`${parseInt(((i / devices.length) * 100))}%\r`);
const page = await browser.newPage();
const pendingXHR = new PendingXHR(page);
await page.goto(url, { waitUntil: 'networkidle2' });
await pendingXHR.waitForAllXhrFinished();
if (withStorage) {
for (let inc = 0; inc < localStorageData.length; inc++) {
const name = localStorageData[inc].name;
const data = localStorageData[inc].data;
await page.evaluate(({name, data}) => {
localStorage.setItem(name, data);
}, {name, data});
}
}
const device = devices[i];