-
Notifications
You must be signed in to change notification settings - Fork 1
/
chatfilterbypass.plugin.js
executable file
·211 lines (187 loc) · 4.78 KB
/
chatfilterbypass.plugin.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
/**
* @name ChatFilterBypass
* @version 1.1.0
* @description Automatically replace cerain letters with characters that look identical but are not to bypass chat filter bots.
* @author danik#4985
*/
class ChatFilterBypass {
#config = null
#saveConfig() {
BdApi.saveData('chatfilterbypass', 'config', JSON.stringify(this.#config))
}
#loadConfig() {
const fetchedDataRaw = BdApi.loadData('chatfilterbypass', 'config')
const defaultConfig = {
ghost: true,
blatant: false,
addSpace: false,
prefix: ''
}
try {
this.#config = JSON.parse(fetchedDataRaw)
} catch {
BdApi.showToast(
'ChatFilterBypass couldn\'t load your config. This is normal if this is your first time using this plugin. New config will be created!',
{
type: 'warn',
icon: true,
timeout: 3500
}
)
this.#config = defaultConfig
this.#saveConfig()
}
}
start() {
if (!global.ZeresPluginLibrary) {
BdApi.showToast('You need Zere\'s plugin library', {
type: 'error',
icon: true,
timeout: 3500
})
return window.BdApi.alert("Library Missing",`The library plugin needed for ChatFilterBypass is missing.<br /><br /> <a href="https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js" target="_blank">Click here to download the library!</a>`)
} else {
ZLibrary.Patcher.after(
'danik.chatfilterbypass.afterSendMessage',
ZLibrary.DiscordModules.MessageActions,
'sendMessage',
(_, _msg) => {
const [, msg] = _msg
console.log(msg)
msg.content = this.#editMessage(msg.content)
}
)
this.#loadConfig()
BdApi.showToast('ChatFilterBypass by danik was activated', {
type: 'success',
icon: true,
timeout: 3500
})
}
}
stop() {
ZLibrary.Patcher.unpatchAll('danik.chatfilterbypass.afterSendMessage')
BdApi.showToast('ChatFilterBypass by danik was deactivated. Bye-bye!', {
type: 'warn',
icon: false,
timeout: 3500
})
}
/**
* Edit the message to bypass chat filters
* @param {string} content
*/
#editMessage(content) {
if (!content.startsWith(this.#config.prefix)) return content
content = content.slice(this.#config.prefix.length)
const EMOJI_REGEX = /<:[a-zA-Z_0-9]+:[0-9]+>/g
const ZWS = '\u{200B}'
const FILTERS_GHOST = {
A: 'Α',
a: 'а',
B: 'Β',
C: 'С',
c: 'с',
E: 'Ε',
e: 'е',
h: 'һ',
I: 'І',
i: 'і',
j: 'ј',
l: 'ӏ',
M: 'Μ',
N: 'Ν',
O: 'О',
o: 'о',
P: 'Ρ',
p: 'р',
T: 'Т',
X: 'Х',
x: 'х',
y: 'у'
}
const FILTERS_BLATANT = {
d: 'ԁ', // Looked different in terminal wtf
e: '℮',
i: '1',
k: 'κ',
n: 'ո',
o: '0',
p: 'ρ',
u: 'ս',
v: 'ν',
z: 'ʐ'
// WIP btw
// someone contribute
// pls
}
const emojiFound = content.match(EMOJI_REGEX) ?? []
const emojiMap = {}
emojiFound.forEach((i, n) => {
content = content.split(i).join(`<:Ř-:${n}>`)
emojiMap[`<:Ř-:${n}>`] = i
})
if (this.#config.ghost) for (const i in FILTERS_GHOST) content = content.split(i).join(FILTERS_GHOST[i])
if (this.#config.blatant) for (const i in FILTERS_BLATANT) content = content.split(i).join(FILTERS_BLATANT[i])
if (this.#config.addSpace) content = content
.split(' ')
.map(
i => /^[a-zA-Z0-9]+$/gm.test(i)
? i.length < 5 ? i[0] + ZWS + i.slice(1) : i[0] + ZWS + i.slice(1, -1) + ZWS + i[i.length - 1]
: i
)
.join(' ')
for (const i in emojiMap) content = content.split(i).join(emojiMap[i])
return content
}
load() {
BdApi.showToast('Thank you for using ChatFilterBypass by danik', {
type: 'info',
icon: true,
timeout: 3500
})
}
getSettingsPanel() {
return ZLibrary.Settings.SettingPanel.build(
() => {
console.log('A setting has changed')
},
new ZLibrary.Settings.Switch(
'Ghost patching',
'Replace letters with identical ones',
this.#config.ghost,
(v) => {
this.#config.ghost = v
this.#saveConfig()
}
),
new ZLibrary.Settings.Switch(
'Blatant patching',
'Replace letters with similiar characters (such as `i` with `1`)',
this.#config.blatant,
(v) => {
this.#config.blatant = v
this.#saveConfig()
}
),
new ZLibrary.Settings.Switch(
'Add zero width spaces',
'Add zero width spaces to words? This will bypass even more advanced filters, but adds extra 1 or 2 characters per word.',
this.#config.addSpace,
(v) => {
this.#config.addSpace = v
this.#saveConfig()
}
),
new ZLibrary.Settings.Textbox(
'Message prefix',
'Only patch message when it starts with some prefix, this will remove the prefix. Leave blank to always patch',
this.#config.prefix,
(v) => {
this.#config.prefix = v
this.#saveConfig()
}
)
)
}
}