-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (24 loc) · 872 Bytes
/
index.js
File metadata and controls
31 lines (24 loc) · 872 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
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({
headless: false,
slowMo: 15, // change this for speed adjustments
defaultViewport: null,
});
const pages = await browser.pages();
const page = pages[0];
await page.goto("https://monkeytype.com", {
waitUntil: "networkidle2",
});
await page.waitForSelector("#words");
// Those three lines are useless you can get rid of them if you want, they just change the theme
await page.keyboard.press("Escape");
await page.keyboard.type("next random theme");
await page.keyboard.press("Enter");
const wordsDiv = await page.$("#words");
for (var i = 0; i < 1000; i++) {
var activeWord = await wordsDiv.$eval(".active", (word) => word.innerText);
await page.keyboard.type(activeWord);
await page.keyboard.type(" ");
}
})();