-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
61 lines (52 loc) · 2.03 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
//Dependencies
const Request = require("request")
const Chalk = require("chalk")
const Fs = require("fs")
//Variables
const Self_Args = process.argv.slice(2)
//Functions
function Initiate_A_Checker(link){
const Dictionary = Fs.readFileSync("./dictionary.txt", "utf8").split("\n")
var dictionary_index = 0
Core()
function Core(){
Request(`${link}${Dictionary[dictionary_index]}`, function(err, res, body){
if(err){
console.log(`${Chalk.grey("[") + Chalk.redBright("INVALID") + Chalk.grey("]")} ${link}${Dictionary[dictionary_index]}`)
dictionary_index += 1
Core()
return
}
if(res.statusCode == 200){
const output_data = Fs.readFileSync("./output.txt", "utf8")
if(output_data.length == 0){
Fs.writeFileSync("./output.txt", `${link}${Dictionary[dictionary_index]}`, "utf8")
}else{
Fs.writeFileSync("./output.txt", `${output_data}\n${link}${Dictionary[dictionary_index]}`, "utf8")
}
console.log(`${Chalk.grey("[") + Chalk.greenBright("VALID") + Chalk.grey("]")} ${link}${Dictionary[dictionary_index]}`)
dictionary_index += 1
Core()
return
}else{
console.log(`${Chalk.grey("[") + Chalk.redBright("INVALID") + Chalk.grey("]")} ${link}${Dictionary[dictionary_index]}`)
dictionary_index += 1
Core()
return
}
})
}
}
//Main
if(Self_Args.length == 0){
console.log(`node index.js <links_file_path>
Example: node index.js ./test_links.txt`)
process.exit()
}
if(!Fs.existsSync(Self_Args[0])){
console.log(`${Chalk.grey("[") + Chalk.redBright("ERROR") + Chalk.grey("]")} Invalid links path.`)
process.exit()
}
for( i = 0; i <= Fs.readFileSync(Self_Args[0], "utf8").split("\n").length-1; i++ ){
Initiate_A_Checker(Fs.readFileSync(Self_Args[0], "utf8").split("\n")[i])
}