| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  | // please no
 | 
					
						
							| 
									
										
										
										
											2014-10-01 13:00:33 +02:00
										 |  |  | module['exports'] = function zalgo(text, options) { | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |   text = text || '   he is here   '; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |   var soul = { | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     'up': [ | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       '̍', '̎', '̄', '̅', | 
					
						
							|  |  |  |       '̿', '̑', '̆', '̐', | 
					
						
							|  |  |  |       '͒', '͗', '͑', '̇', | 
					
						
							|  |  |  |       '̈', '̊', '͂', '̓', | 
					
						
							|  |  |  |       '̈', '͊', '͋', '͌', | 
					
						
							|  |  |  |       '̃', '̂', '̌', '͐', | 
					
						
							|  |  |  |       '̀', '́', '̋', '̏', | 
					
						
							|  |  |  |       '̒', '̓', '̔', '̽', | 
					
						
							|  |  |  |       '̉', 'ͣ', 'ͤ', 'ͥ', | 
					
						
							|  |  |  |       'ͦ', 'ͧ', 'ͨ', 'ͩ', | 
					
						
							|  |  |  |       'ͪ', 'ͫ', 'ͬ', 'ͭ', | 
					
						
							|  |  |  |       'ͮ', 'ͯ', '̾', '͛', | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       '͆', '̚', | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |     ], | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     'down': [ | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       '̖', '̗', '̘', '̙', | 
					
						
							|  |  |  |       '̜', '̝', '̞', '̟', | 
					
						
							|  |  |  |       '̠', '̤', '̥', '̦', | 
					
						
							|  |  |  |       '̩', '̪', '̫', '̬', | 
					
						
							|  |  |  |       '̭', '̮', '̯', '̰', | 
					
						
							|  |  |  |       '̱', '̲', '̳', '̹', | 
					
						
							|  |  |  |       '̺', '̻', '̼', 'ͅ', | 
					
						
							|  |  |  |       '͇', '͈', '͉', '͍', | 
					
						
							|  |  |  |       '͎', '͓', '͔', '͕', | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       '͖', '͙', '͚', '̣', | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |     ], | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     'mid': [ | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       '̕', '̛', '̀', '́', | 
					
						
							|  |  |  |       '͘', '̡', '̢', '̧', | 
					
						
							|  |  |  |       '̨', '̴', '̵', '̶', | 
					
						
							|  |  |  |       '͜', '͝', '͞', | 
					
						
							|  |  |  |       '͟', '͠', '͢', '̸', | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       '̷', '͡', ' ҉', | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   var all = [].concat(soul.up, soul.down, soul.mid); | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   function randomNumber(range) { | 
					
						
							|  |  |  |     var r = Math.floor(Math.random() * range); | 
					
						
							|  |  |  |     return r; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |   function isChar(character) { | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |     var bool = false; | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     all.filter(function(i) { | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       bool = (i === character); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     return bool; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   function heComes(text, options) { | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     var result = ''; | 
					
						
							|  |  |  |     var counts; | 
					
						
							|  |  |  |     var l; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |     options = options || {}; | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |     options['up'] = | 
					
						
							|  |  |  |       typeof options['up'] !== 'undefined' ? options['up'] : true; | 
					
						
							|  |  |  |     options['mid'] = | 
					
						
							|  |  |  |       typeof options['mid'] !== 'undefined' ? options['mid'] : true; | 
					
						
							|  |  |  |     options['down'] = | 
					
						
							|  |  |  |       typeof options['down'] !== 'undefined' ? options['down'] : true; | 
					
						
							|  |  |  |     options['size'] = | 
					
						
							|  |  |  |       typeof options['size'] !== 'undefined' ? options['size'] : 'maxi'; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |     text = text.split(''); | 
					
						
							|  |  |  |     for (l in text) { | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       if (isChar(l)) { | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |         continue; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       result = result + text[l]; | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       counts = {'up': 0, 'down': 0, 'mid': 0}; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       switch (options.size) { | 
					
						
							|  |  |  |       case 'mini': | 
					
						
							|  |  |  |         counts.up = randomNumber(8); | 
					
						
							| 
									
										
										
										
											2014-12-30 20:24:24 -08:00
										 |  |  |         counts.mid = randomNumber(2); | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |         counts.down = randomNumber(8); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       case 'maxi': | 
					
						
							|  |  |  |         counts.up = randomNumber(16) + 3; | 
					
						
							| 
									
										
										
										
											2014-12-30 20:24:24 -08:00
										 |  |  |         counts.mid = randomNumber(4) + 1; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |         counts.down = randomNumber(64) + 3; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       default: | 
					
						
							|  |  |  |         counts.up = randomNumber(8) + 1; | 
					
						
							|  |  |  |         counts.mid = randomNumber(6) / 2; | 
					
						
							|  |  |  |         counts.down = randomNumber(8) + 1; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |       var arr = ['up', 'mid', 'down']; | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |       for (var d in arr) { | 
					
						
							|  |  |  |         var index = arr[d]; | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  |         for (var i = 0; i <= counts[index]; i++) { | 
					
						
							| 
									
										
										
										
											2014-09-30 22:41:24 +02:00
										 |  |  |           if (options[index]) { | 
					
						
							|  |  |  |             result = result + soul[index][randomNumber(soul[index].length)]; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return result; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // don't summon him
 | 
					
						
							| 
									
										
										
										
											2014-12-30 14:57:02 -08:00
										 |  |  |   return heComes(text, options); | 
					
						
							| 
									
										
										
										
											2018-04-30 14:59:34 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 |