-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
225 lines (205 loc) · 5.69 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@500&display=swap"
rel="stylesheet"
/>
<title>Username Generator</title>
<style>
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
font-family: "Roboto Mono", monospace;
background-repeat: no-repeat;
background-attachment: fixed;
background: linear-gradient(to right, #6a3093 0%, #a044ff 100%);
}
a {
text-decoration: none;
color: #fff;
}
.word {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 3em;
font-weight: bold;
text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
color: #fff;
}
.top-left {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: absolute;
top: 0;
left: 0;
transform: translate(5%, 10%);
font-size: 1em;
color: rgba(255, 255, 255, 0.353);
}
.bottom-right {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: absolute;
bottom: 0;
right: 0;
transform: translate(-5%, -10%);
font-size: 0.8em;
color: rgba(255, 255, 255, 0.353);
}
</style>
</head>
<body>
<div class="top-left">
<p>Press [Space]</p>
</div>
<div class="bottom-right">
<span
>All combinations are randomly generated browser-side from a
<a
href="https://github.com/Raais/username/blob/main/words.js"
target="_blank"
>list</a
>
of
</span>
<span id="nouns-count">0</span>
<span> nouns and </span>
<span id="adjectives-count">0</span>
<span> adjectives.</span>
</div>
<div class="word">
<h3 id="word"></h3>
</div>
<script type="text/javascript" src="words.js"></script>
<script>
const randomGradient = () => {
const randomColor = () => {
const letters = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
};
const randomGradient = `linear-gradient(to right, ${randomColor()} 0%, ${randomColor()} 100%)`;
document.body.style.background = randomGradient;
};
const adjectives = words.adjectives;
const nouns = words.nouns;
const combined = words.adjectives.concat(words.nouns);
document.getElementById("nouns-count").innerHTML = nouns.length;
document.getElementById("adjectives-count").innerHTML = adjectives.length;
const randomAdjective = () => {
return adjectives[Math.floor(Math.random() * adjectives.length)];
};
const randomNoun = () => {
return nouns[Math.floor(Math.random() * nouns.length)];
};
const randomWord = () => {
return combined[Math.floor(Math.random() * combined.length)];
};
const randomAdjectiveCombination = () => {
let a;
if (Math.random() < 0.9) {
a = randomAdjective();
} else {
if (Math.random() < 0.6) {
a = randomAdjective() + randomWord();
} else {
a = randomWord() + randomAdjective();
}
}
return a;
};
const randomNounCombination = () => {
let n;
if (Math.random() < 0.9) {
n = randomNoun();
} else {
if (Math.random() < 0.6) {
n = randomNoun() + randomWord();
} else {
n = randomWord() + randomNoun();
}
}
return n;
};
const capitalize = (s) => {
return s.charAt(0).toUpperCase() + s.slice(1);
};
const leetify = (s) => {
return s
.replace(/a/gi, "4")
.replace(/e/gi, "3")
.replace(/i/gi, "1")
.replace(/o/gi, "0");
};
const exify = (s) => {
return s
.replace(/[ae]/gi, "x");
};
const randomStyle = (s) => {
if (Math.random() < 0.4) {
return capitalize(s);
} else {
if (Math.random() < 0.07) {
if (Math.random() < 0.5) {
return leetify(s);
} else {
return exify(s);
}
} else {
return s.toLowerCase();
}
}
};
const randomUsername = () => {
let a = randomStyle(randomAdjectiveCombination());
let b = randomStyle(randomNounCombination());
let u;
if (Math.random() < 0.1) {
let temp = a;
a = b;
b = temp;
}
if (Math.random() < 0.8) {
u = a + b;
} else {
if (Math.random() < 0.5) {
u = a + "_" + b;
} else {
u = a + "." + b;
}
}
return u;
};
const nextWord = () => {
document.getElementById("word").innerHTML = randomUsername();
randomGradient();
};
nextWord();
document.addEventListener("keypress", (e) => {
if (e.key === " ") {
nextWord();
}
});
</script>
</body>
</html>