-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathunfollow.js
76 lines (66 loc) · 1.77 KB
/
unfollow.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
const userField = document.getElementsByClassName("ProfileCard-userFields");
const input = window.prompt("Enter any usernames you want to continue following separated by a space.");
let inputMax = window.prompt("Enter maximum number of seconds to wait between actions. Must be greater than '2'.");
let i = 0;
let t = 0;
let inputFound = [];
let saveNames = input.split(" ");
let rand = Math.round(Math.random() * 10000);
let setMin = 2000;
let setMax = inputMax * 1000;
main();
function main(){
if(inputMax > 2){
randomIntFromInterval(setMin,setMax);
unfollowLoop();
findUsers();
}else{
inputMax = window.prompt("Please enter a number great than 2");
setMax = inputMax * 1000;
main();
}
}
function findUsers(){
if(t < userField.length){
for(u = 0; u < saveNames.length; u++){
if(userField[t].children[1].innerText.includes(saveNames[u])){
inputFound[t] = true;
break;
}else{
inputFound[t] = false;
}
}
t++;
if(t < userField.length){
findUsers();
}
}
}
function randomIntFromInterval(min,max)
{
rand = Math.floor(Math.random()*(max-min+1)+min);
return rand;
}
function unfollowLoop(){
let button = userField[i].previousElementSibling.children[0].children[0].children[0].children[1];
let buttonText = button.innerText;
let stat = userField[i].children[1].children[2];
let follows = "";
if(stat === undefined){
follows = "";
}else{
follows = stat.innerText;
}
setTimeout(function(){
if(follows.includes("Follows you") === false && inputFound[i] === false && buttonText.includes("Following") === true){
button.click();
}
i++;
if(i < userField.length){
randomIntFromInterval(setMin,setMax);
unfollowLoop();
}else{
window.alert("Unfollow Script Finished!");
}
}, rand);
}