-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
33 lines (27 loc) · 955 Bytes
/
index.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
const { React } = require('powercord/webpack');
const ExtendedPlugin = require('./lib/ExtendedPlugin');
const Settings = require("./Settings.jsx");
module.exports = class PowerFindAndReplace extends ExtendedPlugin {
startPlugin() {
powercord.api.settings.registerSettings('powerfnr', {
category: this.entityID,
label: 'Find and Replace',
render: Settings
});
}
pluginWillUnload () {
powercord.api.settings.unregisterSettings('powerfnr');
}
onSendMessage(msg) {
return this.process(msg);
}
process(text) {
var replacements = this.settings.get("replacements", []);
for (let i = 0; i < replacements.length; i++) {
const replace = replacements[i];
if (!replace[0].trim() == '')
while (text.includes(replace[0])) text = text.replace(replace[0], replace[1]);
}
return text;
}
};