-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpreviews.js
More file actions
33 lines (27 loc) · 866 Bytes
/
previews.js
File metadata and controls
33 lines (27 loc) · 866 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
26
27
28
29
30
31
32
33
const puppeteer = require('puppeteer');
const fs = require('fs');
async function create() {
let width = 600
let height = Math.floor(width / 1.91)
console.log(`${width}x${height}`)
fs.readdir('./languages', (err, filenames) => {
for (let file of filenames) {
fs.readFile('./languages/' + file, 'utf-8', async (err, content) => {
let iso = file.split('.')[0]
console.log(iso)
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({
width: width,
height: height,
deviceScaleFactor: 2,
})
await page.goto(`https://whynano.cc/${iso}`);
// console.log()
await page.screenshot({ path: `./client/static/img/preview_${iso}.png` });
await browser.close();
})
}
})
}
create()