-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (51 loc) · 2.06 KB
/
index.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
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
const puppeteer = require('puppeteer');
const CRED = require('./secret.js');
const fs = require('fs');
(async () => {
const sleep = async (ms) => {
return new Promise((res, rej) => {
setTimeout(() => {
res();
}, ms)
});
}
const browser = await puppeteer.launch({ headless: false, defaultViewport: null, });
const page = await browser.newPage();
await page.goto('https://www.messenger.com/', { waitUntil: 'domcontentloaded' });
await page.waitForSelector("#email");
await sleep(500);
// username
await page.type("#email", CRED.username)
await sleep(500);
// password
await page.type("#pass", CRED.password)
await page.click("#loginbutton")
await page.waitForSelector("#js_u > div > div > div._1nq2._7vup > span._5iwm._6-_b._150g._58ah > label > input");
await sleep(1000);
await page.type("#js_u > div > div > div._1nq2._7vup > span._5iwm._6-_b._150g._58ah > label > input", CRED.victimFullName)
await sleep(1000);
var contentSelector = "#js_u > div > div > div._1nq2._7vup > span._5iwm._6-_b._5iwn._150g._58ah > div > div > div:nth-child(2) > ul > li > a > div > div:nth-child(2) > div > div"
await page.waitForSelector(contentSelector, { timeout: 0 });
const resultFullName = await page.$eval(contentSelector, contentSelector => contentSelector.innerText);
if (resultFullName.toLowerCase() !== CRED.victimFullName.toLowerCase()) {
console.log(resultFullName)
console.log("Result name does not equal victim name :(")
browser.close();
return;
} else {
console.log("Success")
}
page.click(contentSelector);
await sleep(5000);
var scriptText = [];
fs.readFileSync('script.txt', 'utf-8').split(/\r?\n/).forEach(async function (line) {
scriptText.push(line)
});
await sleep(5000)
for (line of scriptText) {
await sleep(50);
await page.keyboard.type(line, { delay: 25 })
await page.keyboard.press('Enter');
}
await browser.close();
})();