-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (53 loc) · 2.09 KB
/
index.js
File metadata and controls
64 lines (53 loc) · 2.09 KB
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
const puppeteer = require('puppeteer');
const logger = require('./util/logger');
const config = require('./config.json');
async function main() {
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
headless: true,
args: [
`--window-size=1600,800`,
"--window-position=000,000",
"--disable-dev-shm-usage",
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--single-process',
'--disable-gpu',
"--disable-web-security",
"--disable-features=site-per-process",
],
});
const [page] = await browser.pages();
await page.goto('https://dashboard.tawk.to/login', { timeout: 5000 });
if (page.url() === 'https://dashboard.tawk.to/login') {
const emailInput = await page.waitForXPath('//*[@id="email"]');
await emailInput.type(config.email);
const pwdInput = await page.waitForXPath('//*[@id="password"]');
await pwdInput.type(config.password);
const signInBtn = await page.waitForXPath('//*[@id="submit-login"]');
await signInBtn.click();
await page.waitForNavigation({ waitUntil: "domcontentloaded" });
}
logger.success('Logged in.');
logger.log('Waiting for chat requests...')
while (true) {
try {
await sleep(1);
const newChatBtn = await page.waitForXPath('//*[@id="tawk-navigation-incoming"]/div[2]/div/div');
await newChatBtn.click();
logger.log('New chat detected.')
await sleep(config.takeDelay);
const joinBtn = await page.waitForXPath('/html/body/div[5]/div/div[2]/div[2]/div[1]/div/div[2]/div/div/div/div[1]/div[2]/div/div[2]/div/div[2]/div/div/button');
await joinBtn.click();
logger.success('Joined chat.')
} catch {}
}
}
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
main()