-
Notifications
You must be signed in to change notification settings - Fork 0
/
unfollow-bot.js
69 lines (48 loc) · 3.1 KB
/
unfollow-bot.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
const puppeteer = require('puppeteer');
const iPhone = puppeteer.devices['iPhone X'];
// const iPhonex = devices['iPhone X'];
(function instaBot() {
(async () => {
const browser = await puppeteer.launch({"headless": false,
executablePath:'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
defaultViewport: null, args: ['--start-maximized']});
const page = await browser.newPage();
// await page.emulate(iPhone);
await page.goto('https://www.instagram.com/');
//Wait for cookies to load
await page.waitForSelector( 'body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.bIiDR', {visible: true} );
//Accept cookies
await page.click( 'body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.bIiDR');
await page.waitForSelector('input[name="username"]')
//enter username and password
await page.type('input[name="username"]', 'example username');
await page.type('input[name="password"]', 'example password');
//click submit button
await page.click('button[type="submit"]');
//Don't save acc login
await page.waitForSelector('#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.oJZym > a > div > div > img');
await page.click('#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.oJZym > a > div > div > img');
//No notifications
await page.waitForSelector('body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm');
await page.click('body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm');
//Click on profile page
await page.waitForSelector('#react-root > section > main > section > div.COOzN.MnWb5.YT6rB > div.m0NAq.xrWdL > div > div > div.Igw0E.IwRSH.eGOV_._4EzTm.yC0tu');
await page.click('#react-root > section > main > section > div.COOzN.MnWb5.YT6rB > div.m0NAq.xrWdL > div > div > div.Igw0E.IwRSH.eGOV_._4EzTm.yC0tu');
//Click on following
await page.waitForSelector('#react-root > section > main > div > header > section > ul > li:nth-child(3) > a');
await page.click('#react-root > section > main > div > header > section > ul > li:nth-child(3) > a');
for (let i = 1; i <= 30; i++) {
await page.waitForTimeout(1000);
//Wait and click to unfollow
await page.waitForSelector(`body > div.RnEpo.Yx5HN > div > div > div.isgrP > ul > div > li:nth-child(${i}) > div > div.Igw0E.rBNOH.YBx95.ybXk5._4EzTm.soMvl > button`);
await page.click(`body > div.RnEpo.Yx5HN > div > div > div.isgrP > ul > div > li:nth-child(${i}) > div > div.Igw0E.rBNOH.YBx95.ybXk5._4EzTm.soMvl > button`);
await page.waitForTimeout(1000);
//accept unfollow
await page.waitForSelector('body > div:nth-child(19) > div > div > div > div.mt3GC > button.aOOlW.-Cab_');
await page.click('body > div:nth-child(19) > div > div > div > div.mt3GC > button.aOOlW.-Cab_');
}
await page.waitForTimeout(10000);
await browser.close();
})();
setTimeout(instaBot, 3630000);
})();