改了改,又加了点字符集进去
function getRandomZalgoCharacters() {
const zalgoUp = [
'\u030d', '\u030e', '\u030f', '\u0311', '\u0306',
'\u0310', '\u033d', '\u0305', '\u033e', '\u0304',
'\u0307', '\u0308', '\u030a', '\u030b', '\u030c',
'\u0312', '\u0313', '\u0314', '\u0315', '\u0316'
];
const zalgoDown = [
'\u0320', '\u0321', '\u0322', '\u0323', '\u0324',
'\u0325', '\u0326', '\u0327', '\u0328', '\u0329',
'\u032a', '\u032b', '\u032c', '\u032d', '\u032e',
'\u032f', '\u0330', '\u0331', '\u0332', '\u0333'
];
const zalgoMiddle = [
'\u0334', '\u0335', '\u0336', '\u0337', '\u0338',
'\u0339', '\u0340', '\u0341', '\u0342', '\u0343',
'\u0344', '\u0345', '\u0346', '\u0347', '\u0348',
'\u0349', '\u034a', '\u034b', '\u034c', '\u034d'
];
let result = '';
const totalZalgoCharacters = Math.floor(Math.random() * 3) + 1; // Randomly choose how many characters to add
for (let i = 0; i < totalZalgoCharacters; i++) {
// Randomly add characters from zalgoUp, zalgoDown, and zalgoMiddle
result += zalgoUp[Math.floor(Math.random() * zalgoUp.length)];
result += zalgoMiddle[Math.floor(Math.random() * zalgoMiddle.length)];
result += zalgoDown[Math.floor(Math.random() * zalgoDown.length)];
}
return result;
}
function generateZalgoText(text) {
let zalgoText = '';
for (let char of text) {
zalgoText += char + getRandomZalgoCharacters();
}
return zalgoText;
}
generateZalgoText("like this"); // no support chinese