-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profanity.js
262 lines (255 loc) · 5.39 KB
/
Profanity.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
(function(Scratch) {
'use strict';
const encode = (str) => btoa(str).split('').map((i) => String.fromCharCode(i.charCodeAt(0) + 1)).join('');
const decode = (str) => atob(str.split('').map((i) => String.fromCharCode(i.charCodeAt(0) - 1)).join(''));
// A forewarning for the reader:
// This list contains some very bad naughty words, so we've encoded it in a way that
// it requires a tiny bit of work to read. Most of these words will get you banned from
// Scratch. You have been warned.
const NAUGHTY_WORDS = [
"[oWkbx>>",
"ZYK{[R>>",
"ZYK{[XiwcHV>",
"ZYO{",
"ZYO{[YN>",
"ZYO{[nGk[R>>",
"ZYO{[nGk[YN>",
"ZYO{bH:t[R>>",
"ZYO{bH:t[YN>",
"ZnG{eHGz[B>>",
"ZnG{eHGz[IN>",
"ZnWicnWz",
"ZnWtcHWv[B>>",
"ZnmveB>>",
"Znm1Z3h>",
"Znm1Z3imdx>>",
"Znm1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IN>",
"d3iqeISq[YJ>",
"d3iqeISq[YO1",
"d3iqeISqcnd>",
"d3iqeIS6",
"d3uicnt>",
"d3um[YR>",
"d3yi[x>>",
"d3yicoSmfXV>",
"d3y2eB>>",
"d32idoSid4N>",
"d32idoSid4Omdx>>",
"d32m[x>>",
"d36ieHOp",
"d4CqZx>>",
"d4CqZ3t>",
"d4Ctc3:o[R>>",
"d4Cwc3em",
"eHWiZnGo[3mv[x>>",
"eHm1",
"eHm1bXW{",
"eHm1dx>>",
"eHm1eHmmdx>>",
"eHm1eIl>",
"eH:{d3Wz",
"eH:4[Xyp[XGl",
"eIeieB>>",
"enmjdnG1c4J>",
"e3Gvbx>>",
"e3Gvb3Wz",
"e3W1ZnGkbx>>",
"e3iwdnV>",
"e3m{[XG{dx>>",
"e3m{[XG{d3W{",
"e3:x"
].map(decode);
// Put the longest words first so that if "test" and "tests" are in the word list in
// that order, redacting "tests" will give "***" instead of "***s"
NAUGHTY_WORDS.sort((a, b) => b.length - a.length);
const regex = new RegExp(NAUGHTY_WORDS.join('|'), 'gi');
class Profanity {
getInfo () {
return {
id: 'theshovelprofanity',
name: 'Bad Word Remover',
color1: '#cf6a3c',
color2: '#cf6a3c',
color3: '#cf6a3c',
blocks: [
{
opcode: 'checkProfanity',
blockType: Scratch.BlockType.REPORTER,
text: 'replace bad words in [TEXT] with [REPLACEMENT]',
arguments: {
REPLACEMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: '***',
},
TEXT: {
type: Scratch.ArgumentType.STRING,
defaultValue: 'Hello!',
}
}
},
]
};
}
checkProfanity({TEXT, REPLACEMENT}) {
// Use a function as the second argument so that replacing with "$&" does not allow
// bypass.
return String(TEXT).replace(regex, () => REPLACEMENT);
}
}
Scratch.extensions.register(new Profanity());
})(Scratch);