forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkProfilePicture.plugin.js
32 lines (29 loc) · 1.22 KB
/
linkProfilePicture.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
//META{"name":"linkProfilePicture","source":"https://github.com/Inve1951/BetterDiscordStuff/blob/master/plugins/linkProfilePicture.plugin.js","website":"https://Inve1951.github.io/BetterDiscordStuff"}*//
class linkProfilePicture {
constructor() {
Object.assign(this, ...Object.entries({
getName: "Link-Profile-Picture",
getDescription: "Lets you click users' avatars on their profile page to view a bigger version in your browser.",
getVersion: "1.1.0",
getAuthor: "square"
}).map(([field, value]) => ({ [field]: _ => value })));
}
start() {
const { React } = BdApi;
const memoed = BdApi.findModuleByProps("AnimatedAvatar").AnimatedAvatar;
const AnimatedAvatar = memoed.type;
memoed.type = function LinkProfilePicture(props) {
try {
const vnode = AnimatedAvatar(props).type(props);
vnode.props.onClick = ev => ev.target.parentElement.classList.contains("header-QKLPzZ") &&
window.open(props.src.replace(/(?:\?size=\d{3,4})?$/, "?size=4096"), "_blank");
return vnode;
} catch {}
return React.createElement(AnimatedAvatar, props);
};
this.cancel = _ => memoed.type = AnimatedAvatar;
}
stop() {
this.cancel && this.cancel();
}
}