zalgo
This tag produces zalgo text that goes upwards and downwards
Created by: hackvertor
Installed 1 times
Category: Convert
Created on: Monday, December 2, 2024 at 7:17:01 PM
Updated on: Tuesday, December 3, 2024 at 11:12:53 PM
Tag arguments
[
{
"type": "number",
"help": "This provides the number of zalgo characters to repeat",
"defaultValue": "20"
}
]
Code
class zalgo {
constructor() {
this.upwards = [
"\u030d",
"\u030e",
"\u0304",
"\u0305",
"\u033f",
"\u0311",
"\u0306",
"\u0310",
"\u0352",
"\u0357",
"\u0351",
"\u0307",
"\u0308",
"\u030a",
"\u0342",
"\u0343",
"\u0344",
"\u034a",
"\u034b",
"\u034c",
];
this.downwards = [
"\u0316",
"\u0317",
"\u0318",
"\u0319",
"\u031c",
"\u031d",
"\u031e",
"\u031f",
"\u0320",
"\u0324",
"\u0325",
"\u0326",
"\u0329",
"\u032a",
"\u032b",
"\u032c",
"\u032d",
"\u032e",
"\u0330",
"\u0331",
];
}
encode(text, repeat) {
const zalgoText = text.split("").map((char) => {
const up = this.getRandomChars(this.upwards, repeat);
const down = this.getRandomChars(this.downwards, repeat);
return char + up + down;
});
return zalgoText.join("");
}
getRandomChars(array, count) {
let result = "";
for (let i = 0; i < count; i++) {
result += array[Math.floor(Math.random() * array.length)];
}
return result;
}
}