forked from aahnik/tgcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclockinallan.ts
91 lines (87 loc) · 2.81 KB
/
clockinallan.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const puppeteer = require("puppeteer"); // v22.0.0 or later
(async () => {
const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();
const timeout = 150000;
page.setDefaultTimeout(timeout);
{
const targetPage = page;
await targetPage.setViewport({
width: 993,
height: 750,
});
}
{
const targetPage = page;
const promises = [];
const startWaitingForEvents = () => {
promises.push(targetPage.waitForNavigation());
};
startWaitingForEvents();
await targetPage.goto("https://appx.wheniwork.com/");
await Promise.all(promises);
}
{
await page.waitForSelector("#email");
await page.waitForSelector("#password");
await Promise.all([
await page.type("#email", "[email protected]"),
await page.type("#password", "123onlyfans"),
page.click(".btn-login"), // Clicking the link will indirectly cause a navigation
]);
}
{
const targetPage = page;
await puppeteer.Locator.race([
targetPage.locator("li.dropdown-starts-left > button > i"),
targetPage.locator(
'::-p-xpath(//*[@id=\\"navbarSupportedContent\\"]/ul/li[3]/button/i)'
),
targetPage.locator(":scope >>> li.dropdown-starts-left > button > i"),
])
.setTimeout(timeout)
.click();
await new Promise((resolve) => setTimeout(resolve, 1000));
}
{
const targetPage = page;
await puppeteer.Locator.race([
targetPage.locator("::-p-text(Clock In)"),
targetPage.locator(
"li.dropdown-starts-left > ul > li:nth-of-type(2) span"
),
targetPage.locator(
'::-p-xpath(//*[@id=\\"navbarSupportedContent\\"]/ul/li[2]/ul/li[2]/a/span)'
),
targetPage.locator(
":scope >>> li.dropdown-starts-left > ul > li:nth-of-type(2) span"
),
])
.setTimeout(timeout)
.click({
offset: {
x: 23.925003051757812,
y: 8.599990844726562,
},
});
}
try {
await page.waitForSelector("button.dialog-option-wide", { timeout: 7000 });
const button = await page.$("button.dialog-option-wide");
await button.click();
await new Promise((resolve) => setTimeout(resolve, 500));
} catch (error) {
// If the element is not found, this block will execute
// No action is needed here if you want to silently ignore the error
}
{
await page.waitForSelector("button.btn.btn-primary.btn-md[type='submit']");
const button = await page.$('button.btn.btn-primary.btn-md[type="submit"]');
await button.click();
await new Promise((resolve) => setTimeout(resolve, 3000));
}
await browser.close();
})().catch((err) => {
console.error(err);
process.exit(1);
});