-
Notifications
You must be signed in to change notification settings - Fork 0
/
instagramFollowers.js
92 lines (87 loc) · 2.35 KB
/
instagramFollowers.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* AUTHOR: Sidmaz666
* GITHUB: https://github.com/Sidmaz666
* Open the Browser and go to the following link:
* https://www.instagram.com/username/following/
* Replace username with the username of a user
* Ctrl+Shift+c Open Inspector, Click on the Console Tab.
* Paste the Script and hit Enter!
* Enjoy :)
*
* */
let isScroll = true;
let scrollTime = 5000;
let limit = 0;
let followed = 1;
let followLimit = 150;
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function Follow() {
let totalListLength = document.querySelectorAll(
'[role="dialog"] > div > div > div > div > ._aano > div > div > div'
);
for (let i = 0; i < totalListLength.length; i++) {
const d = totalListLength[i];
const followBtn = d.querySelector("button") || false;
if (followBtn && followBtn.textContent == "Follow") {
followBtn.click();
console.log(
`%c${followed}. Followed ${d
.querySelector('span')
.textContent.replace(/Verified/g, "")
.trim()}`,
"color:cyan;font-style:bold;font-size:18px;"
);
limit++;
followed++;
}
if (limit == 5) {
console.log(
"%cSleeping For 5min!",
"color:orange;font-style:bold;font-size:20px;"
);
limit = 0;
await sleep(300000);
}
if (followed == followLimit) {
console.log("Reach Limit For a Day!");
isScroll = false;
return;
}
}
}
async function scrollAndDetectChildNodes() {
const parentElement = document.querySelector(
'[role="dialog"] > div > div > div > div > ._aano'
);
parentElement.scrollTop = parentElement.scrollHeight;
await sleep(scrollTime);
if (Math.random() > 0.5) {
scrollTime += 5000;
} else {
scrollTime -= 1000;
}
const childNodes = parentElement.children[0].children[0].childNodes;
const addedChildNodes = Array.from(childNodes).filter(
(node) => node.nodeType === Node.ELEMENT_NODE
);
if (addedChildNodes.length > 0) {
isScroll = true;
await Follow();
} else {
isScroll = false;
}
}
(async function () {
console.log("%cPlease Wait!", "color:green;font-style:bold;font-size:22px;");
while (true) {
if (!isScroll) break;
await scrollAndDetectChildNodes();
}
})().then(() => {
console.log(
"%cDone Following!",
"color:green;font-style:bold;font-size:22px;"
);
});