Skip to content

Instantly share code, notes, and snippets.

@secretrobotron
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secretrobotron/651f534a5191dbe360a2 to your computer and use it in GitHub Desktop.
Save secretrobotron/651f534a5191dbe360a2 to your computer and use it in GitHub Desktop.
Incremental Zalgo
// Remixed from http://eeemo.net/ and http://stackoverflow.com/questions/6579844/how-does-zalgo-text-work
// data set of leet unicode chars
//---------------------------------------------------
//those go UP
var zalgo_up = [
'\u030d', /* Ì */ '\u030e', /* ÌŽ */ '\u0304', /* Ì„ */ '\u0305', /* Ì… */
'\u033f', /* Ì¿ */ '\u0311', /* Ì‘ */ '\u0306', /* ̆ */ '\u0310', /* Ì */
'\u0352', /* ͒ */ '\u0357', /* ͗ */ '\u0351', /* ͑ */ '\u0307', /* ̇ */
'\u0308', /* ̈ */ '\u030a', /* ̊ */ '\u0342', /* ͂ */ '\u0343', /* ̓ */
'\u0344', /* ÌˆÌ */ '\u034a', /* ÍŠ */ '\u034b', /* Í‹ */ '\u034c', /* ÍŒ */
'\u0303', /* ̃ */ '\u0302', /* Ì‚ */ '\u030c', /* ÌŒ */ '\u0350', /* Í */
'\u0300', /* Ì€ */ '\u0301', /* Ì */ '\u030b', /* Ì‹ */ '\u030f', /* Ì */
'\u0312', /* ̒ */ '\u0313', /* ̓ */ '\u0314', /* ̔ */ '\u033d', /* ̽ */
'\u0309', /* ̉ */ '\u0363', /* ͣ */ '\u0364', /* ͤ */ '\u0365', /* ͥ */
'\u0366', /* ͦ */ '\u0367', /* ͧ */ '\u0368', /* ͨ */ '\u0369', /* ͩ */
'\u036a', /* ͪ */ '\u036b', /* ͫ */ '\u036c', /* ͬ */ '\u036d', /* ͭ */
'\u036e', /* ͮ */ '\u036f', /* ͯ */ '\u033e', /* ̾ */ '\u035b', /* ͛ */
'\u0346', /* ͆ */ '\u031a' /* ̚ */
];
//those go DOWN
var zalgo_down = [
'\u0316', /* ̖ */ '\u0317', /* ̗ */ '\u0318', /* ̘ */ '\u0319', /* ̙ */
'\u031c', /* Ìœ */ '\u031d', /* Ì */ '\u031e', /* Ìž */ '\u031f', /* ÌŸ */
'\u0320', /* Ì */ '\u0324', /* ̤ */ '\u0325', /* Ì¥ */ '\u0326', /* ̦ */
'\u0329', /* ̩ */ '\u032a', /* ̪ */ '\u032b', /* ̫ */ '\u032c', /* ̬ */
'\u032d', /* ̭ */ '\u032e', /* ̮ */ '\u032f', /* ̯ */ '\u0330', /* ̰ */
'\u0331', /* ̱ */ '\u0332', /* ̲ */ '\u0333', /* ̳ */ '\u0339', /* ̹ */
'\u033a', /* ̺ */ '\u033b', /* ̻ */ '\u033c', /* ̼ */ '\u0345', /* ͅ */
'\u0347', /* ͇ */ '\u0348', /* ͈ */ '\u0349', /* ͉ */ '\u034d', /* Í */
'\u034e', /* ÍŽ */ '\u0353', /* Í“ */ '\u0354', /* Í” */ '\u0355', /* Í• */
'\u0356', /* ͖ */ '\u0359', /* ͙ */ '\u035a', /* ͚ */ '\u0323' /* ̣ */
];
// rand funcs
//---------------------------------------------------
//gets an int between 0 and max
function rand (max) {
return Math.floor(Math.random() * max);
}
//gets a random char from a zalgo char table
function rand_zalgo (array) {
var ind = Math.floor(Math.random() * array.length);
return array[ind];
}
//lookup char to know if its a zalgo char or not
function is_zalgo_char (c) {
var i;
for(i=0; i<zalgo_up.length; i++)
if(c == zalgo_up[i])
return true;
for(i=0; i<zalgo_down.length; i++)
if(c == zalgo_down[i])
return true;
return false;
}
function incremental_zalgo (element) {
var start = Date.now();
var previousText = element.textContent;
var randomIndex;
randomIndex = rand(previousText.length - 2) + 1;
if (is_zalgo_char(previousText[randomIndex])) return;
var firstPart = previousText.substr(0, randomIndex);
var lastPart = previousText.substr(randomIndex);
var newText = '';
var fns = [zalgo_up, zalgo_down];
fns.forEach(function (fn) {
var num = rand(6);
if (Math.random() > 0.7) {
for(var j = 0; j < num; j++) {
newText += rand_zalgo(fn);
}
}
});
element.innerHTML = firstPart + newText + lastPart;
}
setTimeout(function () {
var steps = 100;
(function loop () {
console.log('zalgo approaches');
incremental_zalgo(document.querySelector('h1.title'));
if (steps-- > 0) setTimeout(loop, 250 + Math.round(Math.random() * 1000));
})();
}, 2000 + Math.random() * 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment