Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
263 lines (218 loc) · 9.7 KB
/
Copy pathapp.js
File metadata and controls
263 lines (218 loc) · 9.7 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
(() => {
'use strict';
// ─── DOM References ───────────────────────────────────────────
const form = document.getElementById('profilerForm');
const generateBtn = document.getElementById('generateBtn');
const outputPlaceholder = document.getElementById('outputPlaceholder');
const outputContent = document.getElementById('outputContent');
const outputList = document.getElementById('outputList');
const passwordCounter = document.getElementById('passwordCounter');
const copyBtn = document.getElementById('copyBtn');
const downloadBtn = document.getElementById('downloadBtn');
const searchInput = document.getElementById('searchInput');
const progressContainer = document.getElementById('progressContainer');
const progressBar = document.getElementById('progressBar');
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toastMessage');
let currentPasswords = [];
form.addEventListener('submit', (e) => {
e.preventDefault();
const info = {
firstName: document.getElementById('firstName').value,
lastName: document.getElementById('lastName').value,
nickname: document.getElementById('nickname').value,
dob: document.getElementById('dob').value,
mobile: document.getElementById('mobile').value,
birthYear: document.getElementById('birthYear').value,
partnerName: document.getElementById('partnerName').value,
petName: document.getElementById('petName').value,
childName: document.getElementById('childName').value,
favoriteTeam:document.getElementById('favoriteTeam').value,
areaName: document.getElementById('areaName').value,
pinCode: document.getElementById('pinCode').value,
username: document.getElementById('username').value,
luckyNumber: document.getElementById('luckyNumber').value,
company: document.getElementById('company').value,
keywords: document.getElementById('keywords').value,
};
const hasInput = Object.values(info).some(v => v.trim() !== '');
if (!hasInput) {
showToast('Please fill in at least one field.', true);
return;
}
const count = parseInt(document.getElementById('passwordCount').value) || 200;
const minLen = parseInt(document.getElementById('minLength').value) || 6;
const maxLen = parseInt(document.getElementById('maxLength').value) || 20;
if (minLen > maxLen) {
showToast('Min length cannot be greater than max length.', true);
return;
}
const priorityMode = document.getElementById('priorityMode').checked;
// Disable button
generateBtn.disabled = true;
generateBtn.innerHTML = `
<svg class="spin" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20">
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
</svg>
Generating...
`;
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
// Run engine asynchronously
setTimeout(() => {
const passwords = WorlitEngine.buildWordlist(info, count, minLen, maxLen, priorityMode, (pct, msg) => {
progressBar.style.width = pct + '%';
});
currentPasswords = passwords;
renderPasswords(passwords);
generateBtn.disabled = false;
generateBtn.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20">
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>
</svg>
Generate Wordlist
`;
// Hide progress after a moment
setTimeout(() => {
progressContainer.style.display = 'none';
}, 600);
showToast(`Generated ${passwords.length} passwords!`);
}, 50);
});
function renderPasswords(passwords, highlight = '') {
outputPlaceholder.style.display = 'none';
outputContent.style.display = 'block';
passwordCounter.textContent = passwords.length + ' passwords';
// Virtual rendering for performance (render in batches)
const fragment = document.createDocumentFragment();
passwords.forEach((pw, i) => {
const line = document.createElement('div');
line.className = 'pw-line';
const numSpan = document.createElement('span');
numSpan.className = 'pw-number';
numSpan.textContent = String(i + 1).padStart(4, ' ') + ' ';
const pwSpan = document.createElement('span');
pwSpan.className = 'pw-text';
if (highlight) {
const idx = pw.toLowerCase().indexOf(highlight.toLowerCase());
if (idx >= 0) {
const before = pw.slice(0, idx);
const match = pw.slice(idx, idx + highlight.length);
const after = pw.slice(idx + highlight.length);
pwSpan.innerHTML = escapeHtml(before) +
'<mark class="highlight">' + escapeHtml(match) + '</mark>' +
escapeHtml(after);
line.classList.add('highlight');
} else {
pwSpan.textContent = pw;
}
} else {
pwSpan.textContent = pw;
}
line.appendChild(numSpan);
line.appendChild(pwSpan);
fragment.appendChild(line);
});
outputList.innerHTML = '';
outputList.appendChild(fragment);
}
let searchTimeout;
searchInput.addEventListener('input', () => {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
const query = searchInput.value.trim();
if (!query) {
renderPasswords(currentPasswords);
return;
}
const filtered = currentPasswords.filter(p =>
p.toLowerCase().includes(query.toLowerCase())
);
renderPasswords(filtered, query);
}, 200);
});
copyBtn.addEventListener('click', () => {
if (currentPasswords.length === 0) return;
const text = currentPasswords.join('\n');
navigator.clipboard.writeText(text).then(() => {
copyBtn.classList.add('copied');
copyBtn.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16">
<polyline points="20 6 9 17 4 12"/>
</svg>
Copied!
`;
showToast('Copied ' + currentPasswords.length + ' passwords to clipboard!');
setTimeout(() => {
copyBtn.classList.remove('copied');
copyBtn.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
Copy All
`;
}, 2000);
}).catch(() => {
showToast('Failed to copy — try downloading instead.', true);
});
});
downloadBtn.addEventListener('click', () => {
if (currentPasswords.length === 0) return;
const text = currentPasswords.join('\n');
const blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'worlit_wordlist.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showToast('Downloaded worlit_wordlist.txt');
});
let toastTimeout;
function showToast(message, isError = false) {
toastMessage.textContent = message;
toast.style.borderColor = isError
? 'rgba(239, 68, 68, 0.3)'
: 'var(--border-default)';
toast.classList.add('show');
clearTimeout(toastTimeout);
toastTimeout = setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
//smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const target = document.querySelector(link.getAttribute('href'));
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
const style = document.createElement('style');
style.textContent = `
.spin {
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
mark.highlight {
background: rgba(99, 102, 241, 0.25);
color: var(--text-primary);
border-radius: 2px;
padding: 0 2px;
}
`;
document.head.appendChild(style);
})();