-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
202 lines (186 loc) · 11.2 KB
/
index.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
const fs = require('fs');
const chalk = require('chalk');
const lineReader = require('line-reader');
const {stdin,stdout} = require('process');
const request = require('request');
const readline = require('readline');
const {yellowBright,red,green} = require('chalk');
const settings = require('./settings.json')
const {eachLine} = require('line-reader');
const rl = readline.createInterface({'input': stdin,'output': stdout})
var charArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';
var api = 'https://api.mojang.com/users/profiles/minecraft/';
var xx = 0;
var theLines;
var theLines2;
var theLength;
var theLength2;
var theSep = "\r\n";
var allPwds = "";
var allPwds2 = "";
var newPwd = "";
var logo =
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## ## ###### ## ## ######## ###### ## ## ######## ######## ${chalk.yellowBright(' ## ######')}
### ### ## ## ## ## ## ## ## ## ## ## ## ## ${chalk.yellowBright(' ## ## ## ')}
#### #### ## ## ## ## ## ## ## ## ## ## ${chalk.yellowBright(' ## ## ')}
## ### ## ## ######### ###### ## ##### ###### ######## ${chalk.yellowBright(' ## ###### ')}
## ## ## ## ## ## ## ## ## ## ## ## ${chalk.yellowBright('## ## ## ')}
## ## ## ## ## ## ## ## ## ## ## ## ## ## ${chalk.yellowBright('## ## ## ## ')}
## ## ###### ## ## ######## ###### ## ## ######## ## ## ${chalk.yellowBright(' ###### ###### ')}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
`
console.log(logo)
function mainStep() {
rl.question(chalk.cyanBright('\n[1] Generate / Check\n[2] Settings\n[3] Close\n' + chalk.white('\\> ')), (mainQuestion) => {
switch (mainQuestion) {
case "1":
theLines = settings.strAmount
theLength = settings.strLength
function aio() {
rl.question(chalk.yellow(`\n${chalk.yellowBright('Do you want to use the settings file?\n> ')}`), (useSettings) => {
switch(useSettings) {
case "yes":
theLines = settings.strAmount
theLength = settings.strLength
while (xx < theLines) {
var x = 0;
while (x < theLength) {
newPwd = charArray.charAt(Math.floor(Math.random() * charArray.length));
allPwds += newPwd;
x++
}
allPwds2 = allPwds2 + allPwds + theSep;
allPwds = "";
xx++
}
fs.writeFile('./usernames.txt', allPwds2, function(){})
lineReader.eachLine('./usernames.txt', function(line) {
request(api + line, function (error, response, body) {
if(line.length <= 2 || line.length > 16) return console.log(chalk.redBright(`${line} is invalid.`));
switch (true) {
case String(body) === '':
console.log(line + chalk.greenBright(' is available.'))
fs.appendFile('./availables.txt', `${line}, \n`, function(){})
break;
case String(body).includes(`{"name":`):
console.log(`${chalk.redBright(`${line} is unavailable.`)}`)
break;
}
})
})
rl.close()
break;
case "no":
function theQuestions() {
rl.question('how many characters?\n> ', (chars) => {
theLength2 = chars;
rl.question('how many lines?\n> ', (liness) => {
theLines2 = liness;
while (xx < theLines2) {
var x = 0;
while (x < theLength2) {
newPwd = charArray.charAt(Math.floor(Math.random() * charArray.length));
allPwds += newPwd;
x++
}
allPwds2 = allPwds2 + allPwds + theSep;
allPwds = "";
xx++
}
fs.writeFile('./usernames.txt', allPwds2, function(){})
lineReader.eachLine('./usernames.txt', function(line) {
request(api + line, function (error, response, body) {
if(line.length <= 2 || line.length > 16) return console.log(chalk.redBright(`${line} is invalid.`));
switch (true) {
case String(body) === '':
console.log(line + chalk.greenBright(' is available.'))
fs.appendFile('./availables.txt', `${line}, \n`, function(){})
break;
case String(body).includes(`{"name":`):
console.log(`${chalk.redBright(`${line} is unavailable.`)}`)
break;
}
})
})
})
})
}
rl.close()
break;
}
})
}
aio()
break;
case "2":
function optionStep() {
rl.question(chalk.cyan(`\n [1] View Settings File\n [2] Change Settings\n [3] Back\n ${chalk.white('\\>')} `), (settingsOption) => {
switch(settingsOption) {
case "1":
console.log('\n' + chalk.gray(JSON.stringify(settings, null, 2)))
optionStep()
break;
case "2":
function changeSettingsStep() {
rl.question(chalk.yellowBright('String Length: '), (stringLength) => {
switch(true) {
case (isNaN(stringLength)):
console.log(red('This is not a number.'))
changeSettingsStep()
break;
case (Number(stringLength) > Number(16)):
console.log("This number is greater than 16.")
changeSettingsStep()
break;
default:
JSON.stringify(settings, null, 2)
settings.strLength = stringLength;
fs.writeFile('./settings.json', JSON.stringify(settings, null, 2), function(){})
break;
}
rl.question(chalk.yellowBright('String Amount: '), (stringAmount) => {
switch(true) {
case (isNaN(stringAmount)):
console.log(red('This is not a number.'))
changeSettingsStep()
break;
case (Number(stringAmount) > Number(1000)):
console.log("This number is greater than 1000.")
changeSettingsStep()
break;
default:
JSON.stringify(settings, null, 2)
settings.strAmount = stringAmount;
fs.writeFile('./settings.json', JSON.stringify(settings, null, 2), function(){})
optionStep()
break;
}
})
})
}
changeSettingsStep()
break;
case "3":
mainStep()
break;
default:
console.log("I don't recognize this option.")
optionStep()
break;
}
})
}
optionStep()
break;
case "3":
rl.close()
break;
default:
console.log("\nI don't recognize this option\n")
mainStep()
break;
}
})
}
mainStep()