This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
68 lines (62 loc) · 2.02 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
65
66
67
68
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const lowercase = 'abcdefghijklmnop';
const number = '0123456789';
let settingLength = 3;
let content = '';
function generateString(length) {
let result = '';
const uppercaseLength = uppercase.length;
const lowercaseLength = lowercase.length;
const numberLength = number.length;
for ( let i = 0; i < length; i++ ) {
result += 'https://discord.gift/';
for ( let i = 0; i < 16; i++ ) {
let randInt = Math.floor(Math.random() * 3);
if (randInt === 0) {
result += uppercase.charAt(Math.floor(Math.random() * uppercaseLength));
} else {
if (randInt === 1) {
result += lowercase.charAt(Math.floor(Math.random() * lowercaseLength));
} else {
if (randInt === 2) {
result += number.charAt(Math.floor(Math.random() * numberLength));
}
}
}
}
result += ' \n';
}
return result;
}
function start(lengthsetting) {
const raw = (generateString(lengthsetting));
const str = raw;
const text = document.querySelector(".text");
const input = document.querySelector(".input");
content = str;
function populateText(str) {
let span = document.createElement("span");
span.setAttribute("id", "result");
span.innerText = str;
text.appendChild(span);
}
populateText(str);
}
function updateSettings() {
if (document.getElementById("lengthInput").value.length === 0) {
window.alert('You didn\'t provide any valid length input in the box, so I\'ve defaulted to generating you 3 links.');
start(3);
} else {
let settingLength = document.getElementById("lengthInput").value;
start(settingLength);
}
}
function viewRaw() {
content = document.getElementById("result").innerText;
let rawWindow = window.open("","");
rawWindow.document.write(content);
}
function copyResult() {
const copyText = document.getElementById("result").innerText;
navigator.clipboard.writeText(copyText);
}