This repository has been archived by the owner on Sep 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (59 loc) · 2.61 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const { Plugin } = require('powercord/entities');
const { getModule, getModuleByDisplayName, React } = require('powercord/webpack');
const { inject, uninject } = require('powercord/injector');
const { findInReactTree } = require('powercord/util');
const Tag = require('./Components/tag');
module.exports = class WebTag extends Plugin {
async startPlugin() {
this.loadStylesheet('./style.css');
const MessageTimestamp = getModule([ 'MessageTimestamp' ], false) || getModule(m => (
typeof (m?.__powercordOriginal_default || m.default) === 'function' &&
(m?.__powercordOriginal_default || m.default).toString().includes('showTimestampOnHover')
), false);
const botTagRegularClasses = getModule(['botTagRegular'], false);
const botTagClasses = getModule(['botTagCozy'], false);
const remClasses = getModule(['rem'], false);
inject('webhook-tag-messages', MessageTimestamp, 'default', (args, res) => {
const msg = args[0].message;
if (msg.webhookId !== null && msg.messageReference === null && msg.author.discriminator === '0000') {
const header = findInReactTree(res.props.username, e => Array.isArray(e?.props?.children) && e.props.children.find(c => c?.props?.message));
header.props.children[0].props.message.author.bot = false;
header.props.children.push(React.createElement(
'span',
{
className: `${botTagClasses.botTagCozy} ${botTagClasses.botTagCompact} ${botTagRegularClasses.botTagRegular} ${remClasses.rem}`
},
React.createElement(Tag, {
className: botTagRegularClasses.botText
})
));
}
return res;
});
const AnalyticsContext = await getModuleByDisplayName('AnalyticsContext');
inject('webhook-tag-popout', AnalyticsContext.prototype, 'renderProvider', (_, res) => {
const elements = findInReactTree(res, a => Array.isArray(a) && a.find(c => c && c.type && c.type.displayName === 'CustomStatus'));
if (!elements) return res;
const { user } = findInReactTree(elements, p => p.user);
if (user.discriminator !== '0000' || !user.bot) return res;
elements[1].props.children[1].props.children = [
elements[1].props.children[1].props.children,
React.createElement(
'span',
{
className: `webhook-tag-pop-out ${botTagClasses.botTagCozy} ${botTagClasses.botTagCompact} ` +
`${botTagRegularClasses.botTagRegular} ${remClasses.rem}`
},
React.createElement(Tag, {
className: botTagRegularClasses.botText
})
)
]
return res;
});
}
pluginWillUnload() {
uninject('webhook-tag-messages');
uninject('webhook-tag-popout');
}
};