Marc Kupietz | 02d582a | 2023-10-09 20:11:52 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env node |
| 2 | |
| 3 | const puppeteer = require('puppeteer'); |
| 4 | |
| 5 | function delay(time) { |
| 6 | return new Promise(function (resolve) { |
| 7 | setTimeout(resolve, time) |
| 8 | }); |
| 9 | } |
| 10 | |
| 11 | (async () => { |
| 12 | const browser = await puppeteer.launch({ |
| 13 | headless: "new", |
| 14 | args: ['--no-sandbox'], |
| 15 | defaultViewport: { |
| 16 | width: 1024, |
| 17 | height: 600, |
| 18 | isLandscape: true, |
| 19 | deviceScaleFactor: 1 |
| 20 | } |
| 21 | }); |
| 22 | |
| 23 | const page = await browser.newPage(); |
| 24 | |
| 25 | for (var i = 2; i < process.argv.length; i += 2) { |
| 26 | await page.goto(process.argv[i], { waitUntil: 'networkidle2' }); |
| 27 | await delay(1000); |
| 28 | await page.screenshot({ path: process.argv[i+1] }); |
| 29 | } |
| 30 | |
| 31 | await browser.close(); |
| 32 | })(); |