-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathutils.js
127 lines (114 loc) · 4.33 KB
/
utils.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const fs = require('fs');
const UsernameGenerator = require('username-generator');
const PasswordGenerator = require('generate-password');
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
module.exports.generateId = size => Math.random().toString(36).substr(2, size);
module.exports.generatePassword = () => PasswordGenerator.generate() + '_MK32';
module.exports.generateUsername = () => UsernameGenerator.generateUsername().replace(/-/g, '') + this.generateId(3);
module.exports.generateBirthday = () => ({
day: randomIntFromInterval(1, 30),
month: randomIntFromInterval(1, 12),
year: randomIntFromInterval(1960, 1999),
});
const TwitchClinetID = "kimne78kx3ncx6brgo4mv6wki5h1ko";
module.exports.TwitchClinetID = TwitchClinetID;
module.exports.generateRandomRegisterData = (uname, mail) => ({
username: uname,
password: this.generatePassword(),
birthday: this.generateBirthday(),
email: mail,
client_id: TwitchClinetID,
integrity_token: null
});
let useragents = fs.readFileSync('useragents.txt').toString().replace(/\r/g, '').split("\n");
let proxies = fs.readFileSync('proxy.txt').toString().replace(/\r/g, '').split("\n");
module.exports.MakeRandomID = (length) => {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
}
module.exports.getProxy = (ptype) => {
if(proxies.length == 0)
{
return {};
}
let proxy = proxies[Math.floor(Math.random() * proxies.length)];
let proxy_arry = proxy.split(':');
if(proxy_arry.length == 2)
{
return {
timeout: null,
maxFreeSockets: 1,
maxSockets: 1,
maxTotalSockets: Infinity,
sockets: {},
freeSockets: {},
requests: {},
options: {},
secureProxy: false,
proxy: {
protocol: ptype + ':',
slashes: true,
auth: null,
host: proxy_arry[0],
port: proxy_arry[1],
hostname: proxy_arry[0],
hash: null,
search: null,
query: null,
href: ptype + '://' + proxy_arry[0] + ':' + proxy_arry[1]
}
};
} else if(proxy_arry.length == 4) {
return {
timeout: null,
maxFreeSockets: 1,
maxSockets: 1,
maxTotalSockets: Infinity,
sockets: {},
freeSockets: {},
requests: {},
options: {},
secureProxy: false,
proxy: {
protocol: ptype + ':',
slashes: true,
auth: {
username: proxy_arry[2],
password: proxy_arry[3]
},
host: proxy_arry[0],
port: proxy_arry[1],
hostname: proxy_arry[0],
hash: null,
search: null,
query: null,
href: ptype + '://' + proxy_arry[2] + ':' + proxy_arry[3] + '@' + proxy_arry[0] + ':' + proxy_arry[1]
}
};
} else {
console.log("Proxy is not valid!");
return {};
}
};
module.exports.getUserAgent = () => {
if(useragents.length == 0)
{
return {};
}
let useragent = useragents[Math.floor(Math.random() * useragents.length)];
return useragent;
};
module.exports.convertCookieForRequestHeader = cookies => cookies.map(cookies => cookies.split(';')[0]).join(';');
const avatar_lists = ["pixel-art", "thumbs", "pixel-art-neutral", "personas", "open-peeps", "notionists-neutral", "notionists", "miniavs", "micah", "lorelei-neutral", "lorelei", "fun-emoji", "croodles", "big-smile", "big-ears-neutral", "big-ears", "avataaars-neutral", "avataaars", "adventurer-neutral", "adventurer"];
module.exports.GetAvatarURL = (name) => {
return 'https://api.dicebear.com/6.x/' + avatar_lists[Math.floor(Math.random() * avatar_lists.length)] + '/png?seed=' + name + '&size=300&backgroundColor=' + (Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, '0');
}