forked from E-boi/NSFW-tags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
22 lines (20 loc) · 916 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
const { Plugin } = require('powercord/entities');
const { inject, uninject } = require('powercord/injector');
const { getModule, React } = require('powercord/webpack');
module.exports = class NSFWtags extends Plugin {
async startPlugin() {
this.loadStylesheet('style.css');
const ChannelItem = getModule(m => m.default && m.default.displayName == 'ChannelItem', false);
inject('NSFWtags', ChannelItem, 'default', ([{ channel }], props) => {
const children = props.props.children.props.children[1].props.children[1].props.children;
if (!channel.nsfw) return props;
children.push(React.createElement('div', { className: 'nsfw-badge' }, React.createElement('div', { className: 'nsfw-text' }, 'NSFW')));
return props;
});
ChannelItem.default.displayName = 'ChannelItem';
}
pluginWillUnload() {
uninject('NSFWtags');
document.querySelectorAll('.nsfw-badge').forEach(e => e.remove());
}
};