-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const LETTER_VARIATIONS = { | ||
a: "aAÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎȀȁȂȃẠạẢảấầẩẫậắằẳẴặɐ𝐀𝐚𝑎𝒂𝒜𝒶𝓪𝔞𝕒𝖆𝖺𝗮𝘢𝙖𝚊𝚶𝛂𝜊𝝰𝞐𝞪", | ||
f: "fFƑƒ𝐅𝐟𝑓𝒇𝒻𝓕𝓯𝔣𝕗𝖋𝖥𝗳𝘧𝙛𝚏𝚽𝛣𝜝𝝝𝞥𝟊", | ||
i: "iIÌÍÎÏìíîïĨĩĪīĬĭĮįİıǏǐȈȉȊȋỈỉịɨℹ𝐈𝐢𝑖𝒊𝓘𝓲𝔦𝕚𝖎𝗂𝗜𝗶𝘪𝙞𝚒𝛊𝜄𝝸𝞘𝟗", | ||
r: "rRŔṘŘȐȒṚŖṞṜƦɌⱤŕṙřȑȓṛŗṟṝɍ℞®𝐑𝑟𝑹𝒓ℛ𝓇𝓡𝓻ℜ𝔯𝕽𝖗ℝ𝕣𝚪𝞒", | ||
}; | ||
|
||
export function getRandomTitle() { | ||
let title = ""; | ||
for (let i = 0; i < 1; i++) { | ||
title += getRandomVariation('r') | ||
} | ||
return title; | ||
} | ||
|
||
export function getRandomVariation(characters: string[] | string) { | ||
if (typeof characters === "string") { | ||
characters = characters.split(""); | ||
} | ||
|
||
let variations = []; | ||
characters.forEach((char) => { | ||
if (LETTER_VARIATIONS[char]) { | ||
const letter = getRandomChar(LETTER_VARIATIONS[char]); | ||
variations.push(letter); | ||
} else { | ||
variations.push(char); | ||
} | ||
}); | ||
|
||
return variations; | ||
} | ||
|
||
function getRandomChar(options: string) { | ||
if (Math.random() < 0.01) { | ||
return ""; | ||
} | ||
return options[Math.floor(Math.random() * options.length)]; | ||
} |