-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
47 lines (43 loc) · 1.53 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright (c) 2020 Bowser65
* Licensed under the Open Software License version 3.0
*/
const { Plugin } = require('powercord/entities');
const { findInReactTree } = require('powercord/util');
const { inject, uninject } = require('powercord/injector');
const { React, getModule } = require('powercord/webpack');
module.exports = class QuickStar extends Plugin {
async startPlugin () {
const classes = {
...await getModule([ 'icon', 'isHeader' ]),
...await getModule([ 'button', 'separator', 'wrapper' ])
};
const reactionManager = await getModule([ 'addReaction' ]);
const MiniPopover = await getModule(m => m.default && m.default.displayName === 'MiniPopover');
inject('star-button', MiniPopover, 'default', (_, res) => {
const props = findInReactTree(res, r => r && r.canReact && r.message);
if (!props || props.message.reactions.find(r => r.emoji.name === '⭐' && r.me)) {
return res;
}
res.props.children.unshift(React.createElement(
'div', {
className: classes.button,
onClick: () => reactionManager.addReaction(props.channel.id, props.message.id, {
animated: false,
name: '⭐',
id: null
})
},
React.createElement('img', {
className: `emoji ${classes.icon}`,
src: '/assets/e4d52f4d69d7bba67e5fd70ffe26b70d.svg'
})
));
return res;
});
MiniPopover.default.displayName = 'MiniPopover';
}
pluginWillUnload () {
uninject('star-button');
}
};