Skip to content

Commit a8d1452

Browse files
committed
inital commit
1 parent c261058 commit a8d1452

File tree

5 files changed

+344
-2
lines changed

5 files changed

+344
-2
lines changed

allowcharacters.html

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<!-- MIT License
2+
3+
Copyright (c) 2023 - 2024 treeben77
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE. -->
22+
23+
<head>
24+
<title>AutoMod Regex Generator</title>
25+
<meta property="og:title" content="AutoMod Regex Generator"/>
26+
<meta property="og:description" content="Quickly generate a regex for Discord's AutoMod that will protect your community from using leetspeak to bypass keyword rules."/>
27+
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, width=device-width, user-scalable=no"/>
28+
29+
<link rel="stylesheet" href="static/main.css">
30+
</head>
31+
<body>
32+
<div class="banner-notification banner-critical" id="javascript-disabled">
33+
Enable JavaScript to generate regexes.
34+
</div>
35+
<div class="banner-notification banner-error" id="javascript-disabled-secondary">
36+
Enable JavaScript to generate regexes.
37+
</div>
38+
<script>
39+
document.getElementById("javascript-disabled").hidden = true;
40+
document.getElementById("javascript-disabled-secondary").hidden = true;
41+
</script>
42+
<div class="header">
43+
<a href="/automod-regex-generator/">AutoMod Regex Generator</a>
44+
<div class="pages">
45+
<a href="regexes.html">Regexes</a>
46+
<a href="api.html">API</a>
47+
</div>
48+
</div>
49+
<div class="content">
50+
<p>Generate regexes for Discord's AutoMod that will protect your community from using special characters to bypass auto moderation and send hard to read messages.</p>
51+
52+
<!-- <div class="step">
53+
<p>1. insert bitwise</p>
54+
<input type="number" class="text-input" id="word-input" value="hello world">
55+
</div> -->
56+
57+
<div class="step">
58+
<div class="title-with-right-element">
59+
<p>1. Choose your allowed character classes.</p>
60+
<button class="right-element" id="reset-settings">Reset Settings</button>
61+
</div>
62+
<div class="grid-row smaller-grid-items">
63+
<div class="grid-item">
64+
<input type="checkbox" id="filter-let" checked> Letters
65+
<p>Capital and lowercase English letters, doesn't include accents.</p>
66+
</div>
67+
<div class="grid-item">
68+
<input type="checkbox" id="filter-num" checked> Numbers
69+
<p>All numbers 0 to 9.</p>
70+
</div>
71+
<div class="grid-item">
72+
<input type="checkbox" id="filter-asc" checked> ASCII Symbols
73+
<p>All ASCII symbols excluding letters and numbers (e.g. $, ?, ], ")</p>
74+
</div>
75+
<div class="grid-item">
76+
<input type="checkbox" id="filter-sym" checked> Extended Symbols
77+
<p>Other common symbols used by mobile phones, etc (e.g. ©, ±, ”)</p>
78+
</div>
79+
<div class="grid-item">
80+
<input type="checkbox" id="filter-acc" checked> European Accents
81+
<p>Capital and lowercase letters with European accents (e.g. è, ö, ñ, ß)</p>
82+
</div>
83+
<div class="grid-item">
84+
<input type="checkbox" id="filter-emo" checked> Emojis
85+
<p>Emojis and stuff idk</p>
86+
</div>
87+
<div class="grid-item">
88+
<input type="checkbox" id="filter-cyr"> Cyrillic Characters
89+
<p>Characters from the Cyrillic script (e.g. П, А, Д) <a class="warning-description">These characters can look the same as Latin characters.</a></p>
90+
</div>
91+
<div class="grid-item">
92+
<input type="checkbox" id="filter-kaj"> Kanji Characters
93+
<p>Characters used in Japanese and Chinese (e.g. ん, 例, 好)</p>
94+
</div>
95+
<div class="grid-item">
96+
<input type="checkbox" id="filter-arb"> Arabic Characters
97+
<p>Characters used in Arabric (e.g. ا, ي, ت)</p>
98+
</div>
99+
</div>
100+
</div>
101+
102+
<div class="step">
103+
<p>2. Copy the generated regex!</p>
104+
<div class="error-box" id="regex-error-toolong" hidden>
105+
This Regex is too long! You need to shorten it by shortening the word or disabling some customizer settings!
106+
</div>
107+
<div class="regex-results">
108+
<button id="copy-regex">Copy</button>
109+
<a id="regex-output">
110+
h[e3]ll[o0] w[o0]rld
111+
</a>
112+
</div>
113+
</div>
114+
115+
<p>You can also visit the <a class="link" href="regexes.html">Regexes page</a> to find regexes that block links, zalgo, and more.</p>
116+
117+
<script src="static/allowcharacters.js" type="module"></script>
118+
</div>
119+
<div class="footer">
120+
<div class="footer-left">
121+
AutoMod Regex Generator
122+
123+
<p>© treeben77 2024. Not affiliated with Discord.</p>
124+
</div>
125+
<div class="footer-right">
126+
<p>Made by <a class="link" href="https://treeben77.xyz">treeben77</a></p>
127+
<p>Join the <a class="link" href="https://discord.gg/4CSc9E5uQy">Discord Server</a></p>
128+
<p>View the source on <a class="link" href="https://github.com/treeben77/automod-regex-generator">GitHub</a></p>
129+
</div>
130+
</div>
131+
</body>

generators.js

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,90 @@ function generateLeetspeakRegex(text, settings) {
270270
}
271271
}
272272

273-
export { generateLeetspeakRegex }
273+
const REGEX_CHARACTER_SETS = [
274+
{
275+
setting_bitwise: 1,
276+
value: function(settings) {
277+
if (!(settings & 4)) {
278+
return "a-zA-Z";
279+
} else {return ""};
280+
}
281+
},
282+
{
283+
setting_bitwise: 2,
284+
value: function(settings) {
285+
if (!(settings & 4)) {
286+
return "0-9";
287+
} else {return ""};
288+
}
289+
},
290+
{
291+
setting_bitwise: 4,
292+
value: function(settings) {
293+
if (settings & 1 && settings & 2) {
294+
return "\\p{ASCII}";
295+
} else if (settings & 1) {
296+
return "\\p{ASCII}--[0-9]";
297+
} else if (settings & 2) {
298+
return "\\p{ASCII}--[a-zA-Z]";
299+
} else {
300+
return "\\p{ASCII}--[a-zA-Z0-9]";
301+
}
302+
}
303+
},
304+
{
305+
setting_bitwise: 8,
306+
value: "€…†‡‘’“”•–—™¢£¤¥¦§©®°±²³µ¶¹"
307+
},
308+
{
309+
setting_bitwise: 16,
310+
value: function(settings) {
311+
if (settings & 8) {
312+
return "À-ÿŸ¿¡"
313+
} else {
314+
return "À-ÿŸ"
315+
}
316+
}
317+
},
318+
{
319+
setting_bitwise: 32,
320+
value: "\\p{Extended_Pictographic}\\u{200d}\\u{1f3fb}-\\u{1f3ff}\\u{1f1e6}-\\u{1f1ff}\\u{fe0f}"
321+
},
322+
{
323+
setting_bitwise: 64,
324+
value: "\\u{0400}-\\u{04ff}\\u{0500}-\\u{052f}\\u{a640}-\\u{a69f}\\u{1e030}-\\u{1e08f}\\u{1d2b}-\\u{1d78}\\u{fe2e}-\\u{fe2f}"
325+
},
326+
{
327+
setting_bitwise: 128,
328+
value: "\\u{3000}-\\u{303f}\\u{3040}-\\u{309f}\\u{30a0}-\\u{30ff}\\u{ff00}-\\u{ff9f}\\u{4e00}-\\u{9faf}\\u{3400}-\\u{4dbf}"
329+
},
330+
{
331+
setting_bitwise: 256,
332+
value: "\\u{0621}-\\u{064b}\\u{0660}-\\u{0669}"
333+
}
334+
]
335+
336+
function generateCharacterTypeRegex(text, settings) {
337+
let character_sets = [];
338+
339+
for (var i = 0; i < REGEX_CHARACTER_SETS.length; i++) {
340+
let character_set = REGEX_CHARACTER_SETS[i];
341+
342+
if (settings & character_set.setting_bitwise) {
343+
if (typeof character_set.value === 'function') {
344+
character_sets.push(character_set.value(settings))
345+
} else {
346+
character_sets.push(character_set.value)
347+
}
348+
}
349+
};
350+
351+
let end_text = `[^${character_sets.join('')}]`;
352+
353+
return {
354+
regex: end_text,
355+
too_long: end_text.length > 260
356+
};
357+
};
358+
359+
export { generateLeetspeakRegex, generateCharacterTypeRegex }

static/allowcharacters.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// MIT License
2+
3+
// Copyright (c) 2023 - 2024 treeben77
4+
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import { generateCharacterTypeRegex } from "../generators.js";
24+
25+
const output = document.getElementById("regex-output");
26+
const input = document.getElementById("word-input");
27+
const error_length = document.getElementById("regex-error-toolong");
28+
const reset_settings = document.getElementById("reset-settings");
29+
const copy_output = document.getElementById("copy-regex");
30+
31+
const checkbox_let = document.getElementById("filter-let");
32+
const checkbox_num = document.getElementById("filter-num");
33+
const checkbox_asc = document.getElementById("filter-asc");
34+
const checkbox_sym = document.getElementById("filter-sym");
35+
const checkbox_acc = document.getElementById("filter-acc");
36+
const checkbox_emo = document.getElementById("filter-emo");
37+
const checkbox_cyr = document.getElementById("filter-cyr");
38+
const checkbox_kaj = document.getElementById("filter-kaj");
39+
const checkbox_arb = document.getElementById("filter-arb");
40+
41+
function updateRegex() {
42+
copy_output.innerText = "Copy"
43+
44+
var settings = 0;
45+
settings += checkbox_let.checked << 0
46+
settings += checkbox_num.checked << 1
47+
settings += checkbox_asc.checked << 2
48+
settings += checkbox_sym.checked << 3
49+
settings += checkbox_acc.checked << 4
50+
settings += checkbox_emo.checked << 5
51+
settings += checkbox_cyr.checked << 6
52+
settings += checkbox_kaj.checked << 7
53+
settings += checkbox_arb.checked << 8
54+
55+
// location.hash = btoa(JSON.stringify({
56+
// input: input.value.toLowerCase(),
57+
// settings: settings
58+
// })).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '')
59+
60+
let generated = generateCharacterTypeRegex('', settings)
61+
62+
error_length.hidden = !generated.too_long
63+
output.innerText = generated.regex;
64+
}
65+
66+
reset_settings.onclick = function() {
67+
checkbox_let.checked = true;
68+
checkbox_num.checked = true;
69+
checkbox_asc.checked = true;
70+
checkbox_sym.checked = true;
71+
checkbox_acc.checked = true;
72+
checkbox_emo.checked = true;
73+
checkbox_cyr.checked = false;
74+
checkbox_kaj.checked = false;
75+
checkbox_arb.checked = false;
76+
updateRegex();
77+
};
78+
79+
copy_output.onclick = function() {
80+
navigator.clipboard.writeText(output.innerText);
81+
copy_output.innerText = "Copied!";
82+
setTimeout(function() {
83+
copy_output.innerText = "Copy"
84+
}, 5000);
85+
}
86+
87+
// input.oninput = updateRegex
88+
checkbox_let.onchange = updateRegex
89+
checkbox_num.onchange = updateRegex
90+
checkbox_asc.onchange = updateRegex
91+
checkbox_sym.onchange = updateRegex
92+
checkbox_acc.onchange = updateRegex
93+
checkbox_emo.onchange = updateRegex
94+
checkbox_cyr.onchange = updateRegex
95+
checkbox_kaj.onchange = updateRegex
96+
checkbox_arb.onchange = updateRegex
97+
98+
// if (location.hash.length > 1) {
99+
// const data = JSON.parse(atob(location.hash.replace("#", "").replace('_', '/').replace('-', '+')));
100+
101+
// input.value = data.input;
102+
103+
// checkbox_num.checked = data.settings & 1
104+
// checkbox_sym.checked = data.settings & 2
105+
// checkbox_let.checked = data.settings & 4
106+
// checkbox_emo.checked = data.settings & 8
107+
// checkbox_dub.checked = data.settings & 16
108+
// checkbox_mul.checked = data.settings & 32
109+
// checkbox_whi.checked = data.settings & 64
110+
// checkbox_vow.checked = data.settings & 128
111+
// checkbox_pmc.checked = data.settings & 256
112+
// checkbox_duc.checked = data.settings & 512
113+
// checkbox_uni.checked = data.settings & 1024
114+
// }
115+
116+
updateRegex()

static/main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ body {
186186
color: #f38688;
187187
}
188188

189+
.smaller-grid-items {
190+
flex-basis: 20%;
191+
}
192+
193+
.smaller-grid-items .grid-item {
194+
flex-basis: 20%;
195+
padding-bottom: 15px;
196+
}
197+
189198
.grid-row {
190199
margin-top: 15px;
191200
margin: 10px auto;

static/regexes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const regex_types = [
8585
generator: function(settings) {
8686
const main_invites = `(?:https?:\\/\\/)?(?:www\\.|ptb\\.|canary\\.)?(?:discord(?:app)?\\.(?:(?:com|gg)\\/(?:invite|servers)\\/+[a-z0-9-_]+)|discord\\.gg\\/+[a-z0-9-_]+)`;
8787
if (settings.third_party.checked) {
88-
return `${main_invites}|discord\\.gg/[a-z0-9-_]+)|(?:https?://)?(?:www\\.)?(?:dsc\\.gg|invite\\.gg+|discord\\.link|(?:discord\\.(gg|io|me|li|id))|disboard\\.org)/[a-z0-9-_/]+`;
88+
return `${main_invites}|(?:https?://)?(?:www\\.)?(?:dsc\\.gg|invite\\.gg+|discord\\.link|(?:discord\\.(gg|io|me|li|id))|disboard\\.org)/[a-z0-9-_/]+`;
8989
} else {
9090
return main_invites;
9191
};

0 commit comments

Comments
 (0)