-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
64 lines (43 loc) · 1.71 KB
/
main.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
function run(){
//Getting values from form
const formData = {
targetInfo: document.getElementById("target-info").value
}
const result = process(formData);
document.getElementById("result").innerHTML = result.join(" <br />")
}
function process(formData){
document.getElementById("log").innerHTML = "";
let log = "<br /> Started the creation process...<br />"
console.log("Creating wordList. <br />")
const firstPass = wordGenerator(formData.targetInfo)
console.log("Running second pass. <br />")
console.log("Removing dupicates. <br />")
const result = duplicationRemover(wordGenerator(firstPass))
log += "Finishing. <br />"
document.getElementById("word-count").innerHTML = result.length + " words created.";
console.log("Done")
document.getElementById("log").innerHTML += log +"Done. Copy the wordlist to a txt file."
return result;
}
function wordGenerator(wordList) {
const tinfo = wordList.toString().split(",");
let result = [];
for (let el = 0; el < tinfo.length; el++) { //element inside tinfo
for (let otherEl = 0; otherEl < tinfo.length; otherEl++) {
let joined = ""
for (let index = 0; index < tinfo[otherEl].length; index++) {
if ((tinfo[el] + joined).length <= 20 && (tinfo[el] + joined).length >= 4) {
result.push(tinfo[el] + joined)
}
joined += tinfo[otherEl][index]
}
}
}
return result;
}
function duplicationRemover(wordList) {
return wordList.filter(function(item, pos) {
return wordList.indexOf(item) == pos;
})
}