-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathfb-static.js
68 lines (53 loc) · 2.31 KB
/
fb-static.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
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const AdblockerPlugin = require('puppeteer-extra-plugin-adblocker');
puppeteer.use(AdblockerPlugin({ blockTrackers: true }));
const chromePaths = require('chrome-paths');
const cheerio = require('cheerio');
const sleep = ms => new Promise(res => setTimeout(res, ms));
(async () => {
const browser = await puppeteer.launch({
headless: false,
args: [
"no-sandbox",
"--disable-notifications"
]
});
let allPage = await browser.pages();
const page = await allPage[0];
await page.goto('https://www.facebook.com/login/device-based/regular/login/', {
waitUntil: 'networkidle2',
});
await page.waitForSelector('#email');
await page.focus('#email');
await page.keyboard.type('MASUKAN EMAIL FACEBOOK DISINI');
await page.waitForSelector('#pass');
await page.focus('#pass');
await page.keyboard.type('MASUKAN PASSWORD FACEBOOK DISINI');
const contentHtml = await page.content();
const $ = cheerio.load(contentHtml);
const userinfo = $('span.x1lliihq').text();
const result = $('#loginbutton').attr('id')
console.log("Berhasil Login Dengan username " + userinfo)
await page.waitForSelector(`#${result}`);
await page.evaluate((result) => document.querySelector(`#${result}`).click(), result);
await sleep(10000);
if (page.url() == 'https://www.facebook.com/') {
await page.goto('MASUKAN POSTINGAN DISINI', {
waitUntil: 'networkidle2',
})
console.log("Berhasil Login....")
await sleep(3000,(console.log('Mencoba Comment...\n')));
const comment = await allPage[0]
await comment.waitForSelector('div > .x1ed109x > .xh8yej3 > .x78zum5 > .xi81zsa')
await comment.click('div > .x1ed109x > .xh8yej3 > .x78zum5 > .xi81zsa')
await comment.click('form.x1ed109x');
await sleep(3000,(console.log("Memasukan Comment...\n")));
await comment.keyboard.type('Test Auto Comment Bot');
await page.keyboard.press('Enter');
await sleep(3000,(console.log("Berhasil Comment...")));
} else {
console.log('gagal load halaman nih...')
}
})();