-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
38 lines (38 loc) · 1.31 KB
/
main.js
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
34
35
36
37
38
const puppeteer = require("puppeteer");
const link = "https://10fastfingers.com/text-practice/new";
let page;
(async () => {
try {
const browser = await puppeteer.launch({
headless: false,
args: ["--start-maximized"],
slowMo: 20,
defaultViewport: null,
});
page = await browser.newPage();
await page.goto(link);
await page.waitForSelector(
"#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll"
);
await page.click(
"#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll"
);
let newLink = await page.evaluate((selector) => {
return document.querySelector(selector).getAttribute("href");
}, ".title>a");
newLink = "https://10fastfingers.com" + newLink;
await page.goto(newLink);
await page.waitForSelector("#row1");
let textToType = await page.evaluate((selector) => {
let arr = document.querySelector(selector).innerText;
return arr;
}, "#row1");
await page.waitForSelector("#text_typed");
await page.type("#text_typed",textToType);
} catch (err) {
console.log(err);
}
})();
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});