-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmspa.js
218 lines (207 loc) · 5.69 KB
/
mspa.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/**
* This makes the text of trollchats readable.
*
* Reference: http://mspaintadventures.wikia.com/wiki/Typing_Quirk
*
* ==UserScript==
* @name Trollian
* @description Makes the text of trollchats readable.
* @version 1
* @downloadURL https://raw.github.com/GauntletWizard/trollian/master/mspa.js
* @include http://www.mspaintadventures.com/*
* ==/UserScript==
*/
function swapCase(str) {
var swapped = [];
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) < 96) {
swapped[i] = str.charAt(i).toLowerCase();
} else {
swapped[i] = str.charAt(i).toUpperCase();
}
}
return swapped.join("");
}
// This is stupid, and doesn't work. I'm leaving TC as just toLowerCase.
function stickyCase(str) {
var swapped = [];
for (var i =0; i < str.length; i++) {
if (i % 2) {
if (str.charCodeAt(i) < 96) {
swapped[i] = str.charAt(i).toLowerCase();
} else {
swapped[i] = str.charAt(i).toUpperCase();
}
} else {
if (str.charCodeAt(i) < 96) {
swapped[i] = str.charAt(i).toLowerCase();
} else {
swapped[i] = str.charAt(i).toUpperCase();
}
}
}
return swapped.join("");
}
// Finds the root of the pesterlog, as well as causes it to be displayed.
function findPesterRoot() {
var spoilerwin = document.getElementsByClassName("spoiler")[0];
if (spoilerwin) {
spoilerwin.style.display = "";
spoilerwin.parentNode.children[0].style.display = "None";
var chats = spoilerwin.children[1].children[0].children[0].children[0].children[0].children
return chats
}
}
function twinArmageddons(line) {
// Also known as Sollux Captor
line = line.replace(/two/g, 'to');
line = line.replace(/ii/g, 'i');
line = line.replace(/(\D)2(\D)/g , '$1s$2');
return line;
}
function gallowsCalibrator(line) {
// Also known as Terezi Pyrope
line = line.toLowerCase();
line = line.replace(/3/g, 'e');
line = line.replace(/4/g, 'a');
line = line.replace(/1/g, 'i');
return line;
}
function carcinoGeneticist(line) {
// Also known as Karkat Vantas
line = line.toLowerCase();
return line;
}
function adiosToreador(line) {
// Also known as Tavros Nitram
line = swapCase(line);
return line;
}
function arachnidsGrip(line) {
// Also known as Vriska
//Goddamnit, Vriska, why is your letter usage overloaded?
line = line.replace(/cheapsk8/g, 'cheapskate');
line = line.replace(/8l8tant/g, 'blatant');
line = line.replace(/h8/g, 'hate');
line = line.replace(/gr8/g, 'great');
line = line.replace(/8n't/g, 'ain\'t');
line = line.replace(/8/g, 'b');
line = line.replace(/iiiiiiii/g, 'i');
// I think this one's cute.
// line = line.replace(/::::)/g, ':)');
return line;
}
function terminallyCapricious(line) {
line = line.toLowerCase();
return line;
}
function apocalypseArisen(line) {
// Also known as Aradia Megido
line = line.replace(/0/g, 'o');
return line;
}
function grimAuxiliatrix(line) {
// I Can Survive Having Every Word Capitalized. I've Done CamelCase.
// line = line.toLowerCase();
return line;
}
function arsenicCatnip(line) {
// Also known as Nepeta Leijon
line = ":" + line.slice(10);
//line = line.replace(/:33\ \< /, ' '); // Gack.
line = line.replace(/3/g, 'e');
return line;
}
function centaursTesticle(line) {
// Also known as Equius Zahhak
line = ":" + line.slice(10);
line = line.replace(/0/g, 'o');
line = line.replace(/1/g, 'l');
line = line.replace(/%/g, 'x');
return line;
}
function caligulasAquarium(line) {
// Eridan Ampora
line = line.replace(/ww/g, 'w');
line = line.replace(/vv/g, 'v');
return line;
}
function cuttlefishCuller(line) {
line = line.replace(/\)\(/g, 'h');
return line;
}
// Functions to show/hide the mangled and original versions of text lines.
function showOrig() {
this.getElementsByClassName('orighover')[0].style.display="";
this.getElementsByClassName('mangled')[0].style.display="none";
};
function showMangled(msg) {
this.getElementsByClassName('orighover')[0].style.display="none";
this.getElementsByClassName('mangled')[0].style.display="";
};
function fixChats() {
var pesterlog = findPesterRoot();
if (!pesterlog) {
return;
}
for (l = 0; l < pesterlog.length; l++) {
msg = pesterlog[l];
if (msg.style.color == "rgb(255, 255, 255)") {
msg.style.backgroundColor = "#000000";
}
line = msg.innerHTML.slice(2);
var speaker = msg.innerHTML.substring(0,2);
// TODO: Display original formatting on hover.
switch (speaker) {
case "GC":
case "gc":
line = gallowsCalibrator(line);
break;
case "TA":
case "ta":
line = twinArmageddons(line);
break;
case "CG":
case "cg":
line = carcinoGeneticist(line);
break;
case "AT":
case "at":
line = adiosToreador(line);
break;
case "AG":
case "ag":
line = arachnidsGrip(line);
break;
case "TC":
line = terminallyCapricious(line);
break;
case "AA":
line = apocalypseArisen(line);
break;
case "GA":
line = grimAuxiliatrix(line);
break;
case "AC":
line = arsenicCatnip(line);
break;
case "CT":
line = centaursTesticle(line);
break;
case "CC":
line = cuttlefishCuller(line);
break;
case "CA":
line = caligulasAquarium(line);
break;
default:
continue;
}
msg.innerHTML = '<span class="mangled">' + speaker + line + '</span>' +
'<span class="orighover" style="display:none;">' +
msg.innerHTML + '</span>';
msg.onmouseover = showOrig;
msg.onmouseout = showMangled;
}
};
fixChats();