-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathautoFollowers.js
97 lines (83 loc) · 3.5 KB
/
autoFollowers.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
93
94
95
96
97
const fetch = require('node-fetch');
const mysql = require("mysql");
const delay = require('delay');
const login = require("./lib/login");
const Follow = require("./lib/follow");
const getCookie = require('./lib/getCookie');
const moment = require('moment');
const colors = require("./lib/colors");
const UA = require('./lib/utils/uaGen');
const getUserId = require('./lib/getUSerId');
const readlineSync = require('readline-sync');
require('dotenv').config();
const connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
});
console.log("");
console.log("");
const username = readlineSync.question('Masukan username target : ');
console.log("");
console.log("");
(async () => {
const newData = [];
const userId = await getUserId.functionGetUserId(username);
const user_agent = await UA.returnUA();
await connection.query(
`SELECT * FROM user`,
function (error, results, fields) {
if (error) return 'error';
delay(5000)
results.map(test => {
newData.push(test);
})
}
);
await delay(5000);
for (let index = 0; index < newData.length; index++) {
const element = newData[index];
await delay(2000)
const Cookie = await getCookie.functionGetCookie(user_agent);
const csrfToken = Cookie[7].split(';')[0];
const rurz = Cookie[8].split(';')[0];
const mid = Cookie[9].split(';')[0];
const LoginToDO = await login.functionLogin(element.username, element.password, csrfToken, rurz, mid, user_agent);
const getCookies = await login.functionGetCookie(element.username, element.password, csrfToken, rurz, mid, user_agent);
console.log(getCookies.extensions)
if (LoginToDO.authenticated === true) {
if (getCookies.extensions.join().split(',')[9] !== undefined) {
const shbid = getCookie.extensions.join().split(',')[1];
const shbts = getCookie.extensions.join().split(',')[3];
const rur = getCookies.extensions.join().split(',')[5];
const ds = getCookies.extensions.join().split(',')[7];
const sessionId = getCookies.extensions.join().split(',')[9];
const post = {
username: element.username,
password: element.password
}
await delay(1000);
const follow = await Follow.functionFollow(csrfToken, mid, ds, rur, sessionId, shbid, shbts, username, userId, user_agent);
if (follow.status === 'ok') {
console.log(follow, post.username)
}
} else {
const rur = getCookies.extensions.join().split(',')[1];
const ds = getCookies.extensions.join().split(',')[3];
const sessionId = getCookies.extensions.join().split(',')[5];
const post = {
username: element.username,
password: element.password
}
const shbidddd = '';
const shbtsss = '';
await delay(1000);
const follow = await Follow.functionFollow(csrfToken, mid, ds, rur, sessionId, shbidddd, shbtsss, username, userId, user_agent);
if (follow.status === 'ok') {
console.log(follow, post.username)
}
}
}
}
})();