1 | // please no
|
---|
2 | module['exports'] = function zalgo(text, options) {
|
---|
3 | text = text || ' he is here ';
|
---|
4 | var soul = {
|
---|
5 | 'up': [
|
---|
6 | '̍', '̎', '̄', '̅',
|
---|
7 | '̿', '̑', '̆', '̐',
|
---|
8 | '͒', '͗', '͑', '̇',
|
---|
9 | '̈', '̊', '͂', '̓',
|
---|
10 | '̈', '͊', '͋', '͌',
|
---|
11 | '̃', '̂', '̌', '͐',
|
---|
12 | '̀', '́', '̋', '̏',
|
---|
13 | '̒', '̓', '̔', '̽',
|
---|
14 | '̉', 'ͣ', 'ͤ', 'ͥ',
|
---|
15 | 'ͦ', 'ͧ', 'ͨ', 'ͩ',
|
---|
16 | 'ͪ', 'ͫ', 'ͬ', 'ͭ',
|
---|
17 | 'ͮ', 'ͯ', '̾', '͛',
|
---|
18 | '͆', '̚',
|
---|
19 | ],
|
---|
20 | 'down': [
|
---|
21 | '̖', '̗', '̘', '̙',
|
---|
22 | '̜', '̝', '̞', '̟',
|
---|
23 | '̠', '̤', '̥', '̦',
|
---|
24 | '̩', '̪', '̫', '̬',
|
---|
25 | '̭', '̮', '̯', '̰',
|
---|
26 | '̱', '̲', '̳', '̹',
|
---|
27 | '̺', '̻', '̼', 'ͅ',
|
---|
28 | '͇', '͈', '͉', '͍',
|
---|
29 | '͎', '͓', '͔', '͕',
|
---|
30 | '͖', '͙', '͚', '̣',
|
---|
31 | ],
|
---|
32 | 'mid': [
|
---|
33 | '̕', '̛', '̀', '́',
|
---|
34 | '͘', '̡', '̢', '̧',
|
---|
35 | '̨', '̴', '̵', '̶',
|
---|
36 | '͜', '͝', '͞',
|
---|
37 | '͟', '͠', '͢', '̸',
|
---|
38 | '̷', '͡', ' ҉',
|
---|
39 | ],
|
---|
40 | };
|
---|
41 | var all = [].concat(soul.up, soul.down, soul.mid);
|
---|
42 |
|
---|
43 | function randomNumber(range) {
|
---|
44 | var r = Math.floor(Math.random() * range);
|
---|
45 | return r;
|
---|
46 | }
|
---|
47 |
|
---|
48 | function isChar(character) {
|
---|
49 | var bool = false;
|
---|
50 | all.filter(function(i) {
|
---|
51 | bool = (i === character);
|
---|
52 | });
|
---|
53 | return bool;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | function heComes(text, options) {
|
---|
58 | var result = '';
|
---|
59 | var counts;
|
---|
60 | var l;
|
---|
61 | options = options || {};
|
---|
62 | options['up'] =
|
---|
63 | typeof options['up'] !== 'undefined' ? options['up'] : true;
|
---|
64 | options['mid'] =
|
---|
65 | typeof options['mid'] !== 'undefined' ? options['mid'] : true;
|
---|
66 | options['down'] =
|
---|
67 | typeof options['down'] !== 'undefined' ? options['down'] : true;
|
---|
68 | options['size'] =
|
---|
69 | typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
|
---|
70 | text = text.split('');
|
---|
71 | for (l in text) {
|
---|
72 | if (isChar(l)) {
|
---|
73 | continue;
|
---|
74 | }
|
---|
75 | result = result + text[l];
|
---|
76 | counts = {'up': 0, 'down': 0, 'mid': 0};
|
---|
77 | switch (options.size) {
|
---|
78 | case 'mini':
|
---|
79 | counts.up = randomNumber(8);
|
---|
80 | counts.mid = randomNumber(2);
|
---|
81 | counts.down = randomNumber(8);
|
---|
82 | break;
|
---|
83 | case 'maxi':
|
---|
84 | counts.up = randomNumber(16) + 3;
|
---|
85 | counts.mid = randomNumber(4) + 1;
|
---|
86 | counts.down = randomNumber(64) + 3;
|
---|
87 | break;
|
---|
88 | default:
|
---|
89 | counts.up = randomNumber(8) + 1;
|
---|
90 | counts.mid = randomNumber(6) / 2;
|
---|
91 | counts.down = randomNumber(8) + 1;
|
---|
92 | break;
|
---|
93 | }
|
---|
94 |
|
---|
95 | var arr = ['up', 'mid', 'down'];
|
---|
96 | for (var d in arr) {
|
---|
97 | var index = arr[d];
|
---|
98 | for (var i = 0; i <= counts[index]; i++) {
|
---|
99 | if (options[index]) {
|
---|
100 | result = result + soul[index][randomNumber(soul[index].length)];
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 | }
|
---|
105 | return result;
|
---|
106 | }
|
---|
107 | // don't summon him
|
---|
108 | return heComes(text, options);
|
---|
109 | };
|
---|
110 |
|
---|