Skip to content

Commit 147ac61

Browse files
committed
inital commit - maybe this will work
0 parents  commit 147ac61

File tree

6 files changed

+568
-0
lines changed

6 files changed

+568
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.py

index.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<head>
2+
<link rel="stylesheet" href="/static/main.css">
3+
</head>
4+
<body>
5+
<div class="header">
6+
<a href="/templates/index.html">AutoMod Regex Generator</a>
7+
<div class="pages">
8+
<a href="/templates/spam.html">Spam</a>
9+
</div>
10+
</div>
11+
<div class="content">
12+
<p>Quickly generate a regex for Discord's AutoMod that will protect your community from using leetspeak to bypass keyword rules.</p>
13+
14+
<p>Start by inputing a keyword you'd like to be filtered with a regex.</p>
15+
<input type="text" class="text-input" id="word-input" value="Hello World">
16+
17+
<p>You can change some settings to customize the results if you'd like:</p>
18+
<div class="grid-row">
19+
<div class="grid-item">
20+
<input type="checkbox" id="filter-num" checked> Number Variants
21+
<p>Prevents character replacements using numbers. (e.g. he11o)</p>
22+
</div>
23+
<div class="grid-item">
24+
<input type="checkbox" id="filter-sym" checked> Symbol Variants
25+
<p>Prevents character replacements using symbols. (e.g. he!!o)</p>
26+
</div>
27+
<div class="grid-item">
28+
<input type="checkbox" id="filter-let" checked> Letter Variants
29+
<p>Prevents character replacements using different letters. (e.g. heiio)</p>
30+
</div>
31+
</div>
32+
33+
<div class="grid-row">
34+
<div class="grid-item">
35+
<input type="checkbox" id="filter-emo" checked> Emoji Variants
36+
<p>Prevents replacing a character with regional indicator emojis. (e.g. hell🅾️)</p>
37+
</div>
38+
<div class="grid-item">
39+
<input type="checkbox" id="double-spm" checked> Double-letter Spam
40+
<p>Prevents spamming characters which are normally next to each other multiple times. (e.g. hellllo)</p>
41+
</div>
42+
<div class="grid-item">
43+
<input type="checkbox" id="multi-char"> Multi Character
44+
<p>Prevents replacing a character with multiple. (e.g. |-|ello)</p>
45+
</div>
46+
</div>
47+
48+
<div class="grid-row">
49+
<div class="grid-item">
50+
<input type="checkbox" id="whitespace"> Extra Whitespace
51+
<p>Prevents adding spaces unnecessary. (e.g. he llo) This could make the regex really long</p>
52+
</div>
53+
<div class="grid-item">
54+
<input type="checkbox" id="vowel-less"> Vowelless Variants
55+
<p>Prevents removing the vowels. (e.g. hllo) <a id="warning-description">This could cause false positives!</a></p>
56+
</div>
57+
</div>
58+
59+
<p>...And here's your regex!</p>
60+
<div class="error-box" id="regex-error-toolong" hidden>
61+
This Regex is too long! You need to shorten it by shorten the word or disabling some customizer settings, Double-letter Spam makes the regex smaller but everything else makes it longer.
62+
</div>
63+
<a id="regex-output">
64+
h[e3]ll[o0] w[o0]rld
65+
</a>
66+
67+
<p>Zalgo can bypass the regex. <a class="link" href="/templates/spam.html">You can generate regexes for zalgo and other spam too!</a></p>
68+
69+
<script src="/static/index.js"></script>
70+
</div>
71+
</body>

spam.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<head>
2+
<link rel="stylesheet" href="/static/main.css">
3+
</head>
4+
<body>
5+
<div class="header">
6+
<a href="/templates/index.html">AutoMod Regex Generator</a>
7+
<div class="pages">
8+
<a href="/templates/spam.html">Spam</a>
9+
</div>
10+
</div>
11+
<div class="content">
12+
Block messages with zalgo, too many emojis and too many newlines!
13+
<div class="spam-type">
14+
<a class="spam-name">Zalgo</a>
15+
<div class="grid-row">
16+
<div class="grid-item">
17+
<p>Zalgo text is designed to make the message obfucated, and be very annoying for other members. (e.g. h̵̅ͅȇ̴̫l̸͇͌l̸̝͛ȍ̴̱) </p>
18+
<div class="setting">
19+
<input type="checkbox" id="filter-accents"> Filter Accents
20+
<p>When disabled, messages with accents will be allowed (e.g. héllo) but this can also cause some false negatives.</p>
21+
</div>
22+
</div>
23+
<div class="grid-item grid-item-right">
24+
...And here's your regex!<br><br>
25+
<a class="regex-output" id="regex-output-zalgo">
26+
\p{M}{3,}
27+
</a>
28+
</div>
29+
</div>
30+
</div>
31+
<div class="spam-type">
32+
<a class="spam-name">Emoji Spam</a>
33+
<div class="grid-row">
34+
<div class="grid-item">
35+
<p>Prevents emoji spam in messages by setting a limit for each message.</p>
36+
<div class="setting">
37+
Maximum Allowed Emojis<br>
38+
<a id="emoji-range-value">0<a></a> <input type="range" id="emoji-range" min="0" max="12" value="6">
39+
<p>Maximum number of standarad and custom emojis per message. The highest possible is 12 due to Discord limitations.</p>
40+
</div>
41+
</div>
42+
<div class="grid-item grid-item-right">
43+
...And here's your regex!<br><br>
44+
<a class="regex-output" id="regex-output-emoji">
45+
(?s)((<a?:[a-z_0-9]+:[0-9]+>|\p{Extended_Pictographic}).*){2,}
46+
</a>
47+
</div>
48+
</div>
49+
</div>
50+
<div class="spam-type">
51+
<a class="spam-name">Newline Spam</a>
52+
<div class="grid-row">
53+
<div class="grid-item">
54+
<p>Limits the number of newlines per mesage. Note that newlines and lines are not the same.</p>
55+
<div class="setting">
56+
Maximum Allowed Newlines<br>
57+
<input type="number" id="max-newlines" value="5">
58+
<p>Maxiumum number of newlines per message.</p>
59+
</div>
60+
</div>
61+
<div class="grid-item grid-item-right">
62+
...And here's your regex!<br><br>
63+
<a class="regex-output" id="regex-output-newline">
64+
(\n.*){6,}
65+
</a>
66+
</div>
67+
</div>
68+
</div>
69+
<script src="/static/spam.js"></script>
70+
</div>
71+
</body>

static/index.js

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
const output = document.getElementById("regex-output")
2+
const input = document.getElementById("word-input")
3+
const error_length = document.getElementById("regex-error-toolong")
4+
5+
const checkbox_num = document.getElementById("filter-num")
6+
const checkbox_sym = document.getElementById("filter-sym")
7+
const checkbox_let = document.getElementById("filter-let")
8+
const checkbox_emo = document.getElementById("filter-emo")
9+
const checkbox_dub = document.getElementById("double-spm")
10+
const checkbox_mul = document.getElementById("multi-char")
11+
const checkbox_vow = document.getElementById("vowel-less")
12+
const checkbox_whi = document.getElementById("whitespace")
13+
14+
const numReplacers = {
15+
"i": ["1"],
16+
"l": ["1"],
17+
"e": ["3"],
18+
"a": ["4"],
19+
"t": ["7"],
20+
"b": ["8"],
21+
"g": ["9"],
22+
"o": ["0"]
23+
};
24+
25+
const symReplacers = {
26+
"i": ["!", "|"],
27+
"l": ["!", "|"],
28+
"s": ["\\$"],
29+
"h": ["\\|-\\|"],
30+
"n": ["|\\|"],
31+
"c": ["\\("],
32+
"k": ["\\|<"],
33+
"a": ["@", "∆", "/-\\", "/_\\", "/\\", "Д"],
34+
"b": ["|}", "|:", "|8", "ß", "ь"]
35+
};
36+
37+
const letReplacers = {
38+
"i": ["l"],
39+
"l": ["i"],
40+
"u": ["v"],
41+
"m": ["nn", "rn"],
42+
"w": ["vv", "uu"]
43+
};
44+
45+
const emoReplacers = {
46+
"a": ["🇦", "🅰️"],
47+
"b": ["🇧", "🅱️"],
48+
"c": ["🇨", "©️"],
49+
"d": ["🇩"],
50+
"e": ["🇪"],
51+
"f": ["🇫"],
52+
"g": ["🇬"],
53+
"h": ["🇭"],
54+
"i": ["🇮", "ℹ️"],
55+
"j": ["🇯"],
56+
"k": ["🇰"],
57+
"l": ["🇱"],
58+
"m": ["🇲", "Ⓜ️"],
59+
"n": ["🇳"],
60+
"o": ["🇴", "🅾️⭕"],
61+
"p": ["🇵", "🅿️"],
62+
"q": ["🇶"],
63+
"r": ["🇷", "®️"],
64+
"s": ["🇸"],
65+
"t": ["🇹", "✝️"],
66+
"u": ["🇺"],
67+
"v": ["🇻"],
68+
"w": ["🇼"],
69+
"x": ["🇽", "❌", "❎", "✖️"],
70+
"y": ["🇾"],
71+
"z": ["🇿"],
72+
"1": ["1️⃣"],
73+
"2": ["2️⃣"],
74+
"3": ["3️⃣"],
75+
"4": ["4️⃣"],
76+
"5": ["5️⃣"],
77+
"6": ["6️⃣"],
78+
"7": ["7️⃣"],
79+
"8": ["8️⃣"],
80+
"9": ["9️⃣"],
81+
"0": ["0️⃣"]
82+
};
83+
84+
function updateRegex() {
85+
let start_text;
86+
if (!input.value == "") {
87+
start_text = input.value.toLowerCase();
88+
} else {
89+
start_text = "hello world";
90+
};
91+
92+
let end_text = "";
93+
let previous_charater;
94+
let previous_charater_combo = 0;
95+
let previous_charater_modified = false;
96+
for (var i = 0; i < start_text.length; i++) {
97+
let character = (start_text[i]);
98+
let replacers = [];
99+
100+
if (character == previous_charater & previous_charater_modified) {
101+
previous_charater_combo++;
102+
continue;
103+
} else if (previous_charater_combo > 0 & previous_charater_modified) {
104+
if (checkbox_dub.checked) {
105+
end_text = end_text.concat(`{${previous_charater_combo + 1},}`);
106+
} else {
107+
end_text = end_text.concat(`{${previous_charater_combo + 1}, ${previous_charater_combo + 1}}`);
108+
}
109+
previous_charater_combo = 0;
110+
previous_charater_modified = false;
111+
};
112+
113+
if (checkbox_num.checked) {
114+
const numbers = numReplacers[character];
115+
if (numbers) {
116+
for (var i2 = 0; i2 < numbers.length; i2++) {
117+
replacers.push(numbers[i2]);
118+
};
119+
};
120+
};
121+
122+
if (checkbox_sym.checked) {
123+
const symbols = symReplacers[character];
124+
if (symbols) {
125+
for (var i2 = 0; i2 < symbols.length; i2++) {
126+
replacers.push(symbols[i2]);
127+
};
128+
};
129+
};
130+
131+
if (checkbox_let.checked) {
132+
const letters = letReplacers[character];
133+
if (letters) {
134+
for (var i2 = 0; i2 < letters.length; i2++) {
135+
replacers.push(letters[i2]);
136+
};
137+
};
138+
};
139+
140+
if (checkbox_emo.checked) {
141+
const emojis = emoReplacers[character];
142+
if (emojis) {
143+
for (var i2 = 0; i2 < emojis.length; i2++) {
144+
replacers.push(emojis[i2]);
145+
};
146+
};
147+
};
148+
149+
let is_all_one_char = true
150+
for (var i2 = 0; i2 < replacers.length; i2++) {
151+
let replacer = replacers[i2];
152+
153+
if (replacer == null) {break}
154+
155+
if (replacer.replace("\\", "").length > 1 & checkbox_mul.checked) {
156+
is_all_one_char = false
157+
} else if (/\p{Extended_Pictographic}/u.test(replacer)) {
158+
//pass
159+
} else if (replacer.length > 2) {
160+
replacers.splice(i2, 1)
161+
i2--
162+
}
163+
};
164+
165+
if (checkbox_whi.checked & !end_text == "") {
166+
end_text = end_text.concat("\\s*")
167+
}
168+
if (replacers.length == 0) {
169+
end_text = end_text.concat(character);
170+
} else {
171+
if (is_all_one_char) {
172+
end_text = end_text.concat(`[${character}${replacers.join('')}]`);
173+
} else {
174+
end_text = end_text.concat(`(${character}|${replacers.join('|')})`);
175+
}
176+
previous_charater_modified = true;
177+
};
178+
179+
if (checkbox_vow.checked & (character == "a" || character == "e" || character == "i" || character == "o" || character == "u")) {
180+
end_text = end_text.concat("?")
181+
};
182+
183+
previous_charater = character;
184+
};
185+
186+
if (previous_charater_combo > 0 & previous_charater_modified) {
187+
if (checkbox_dub.checked) {
188+
end_text = end_text.concat(`{${previous_charater_combo + 1},}`);
189+
} else {
190+
end_text = end_text.concat(`{${previous_charater_combo + 1}, ${previous_charater_combo + 1}}`);
191+
}
192+
previous_charater_combo = 0;
193+
previous_charater_modified = false;
194+
};
195+
196+
if (end_text.length > 260) {
197+
error_length.hidden = false
198+
} else {
199+
error_length.hidden = true
200+
}
201+
202+
output.innerText = end_text;
203+
}
204+
205+
input.oninput = updateRegex
206+
checkbox_num.onchange = updateRegex
207+
checkbox_sym.onchange = updateRegex
208+
checkbox_let.onchange = updateRegex
209+
checkbox_dub.onchange = updateRegex
210+
checkbox_mul.onchange = updateRegex
211+
checkbox_vow.onchange = updateRegex
212+
checkbox_whi.onchange = updateRegex
213+
checkbox_emo.onchange = updateRegex
214+
updateRegex()

0 commit comments

Comments
 (0)