forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HighlightSelf.plugin.js
110 lines (93 loc) · 3.18 KB
/
HighlightSelf.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* @name Highlight Self
* @description Highlights your own username in message headers.
* @version 1.2.2
* @author square
* @authorLink https://betterdiscord.app/developer/square
* @website https://betterdiscord.app/plugin/Highlight%20Self
* @source https://github.com/Inve1951/BetterDiscordStuff/blob/master/coffee/HighlightSelf.plugin.coffee
* @updateUrl https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/HighlightSelf.plugin.js
* @exports 42
*/
var HighlightSelf;
module.exports = HighlightSelf = function () {
var UserStore, YouTellMe, cancel, css, install, patchRender;
class HighlightSelf {
load() {
return window.SuperSecretSquareStuff != null ? window.SuperSecretSquareStuff : window.SuperSecretSquareStuff = new Promise(function (c, r) {
return require("request").get("https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/0circle.plugin.js", function (err, res, body) {
if (err || 200 !== (res != null ? res.statusCode : void 0)) {
return r(err != null ? err : res);
}
Object.defineProperties(window.SuperSecretSquareStuff, {
libLoaded: {
value: c
},
code: {
value: body
}
});
return (0, eval)(body);
});
});
}
async start() {
({
patchRender
} = await SuperSecretSquareStuff);
if (!install()) {
this.onSwitch = install;
}
return BdApi.injectCSS("css_highlightSelf", css);
}
stop() {
delete this.onSwitch;
if (cancel) {
cancel();
cancel = null;
}
return BdApi.clearCSS("css_highlightSelf");
}
}
;
YouTellMe = UserStore = cancel = patchRender = null;
install = function () {
YouTellMe || (YouTellMe = BdApi.findModule(function (m) {
return "function" === typeof (m != null ? m.default : void 0) && m.default.toString().includes("getGuildMemberAvatarURLSimple");
}));
UserStore || (UserStore = BdApi.findModuleByProps("getCurrentUser"));
if (!(YouTellMe && UserStore)) {
return false;
}
if (this !== window) {
delete this.onSwitch;
}
cancel = patchRender(YouTellMe, {
filter: function (node, {
message: {
author
}
}) {
var ref;
return UserStore.getCurrentUser() === author && ((ref = node.props.children) != null ? typeof ref.some === "function" ? ref.some(function (child) {
return (child != null ? child.type : void 0) === "h2";
}) : void 0 : void 0);
},
touch: function (node) {
var ref, ref1;
node = node.props.children.find(function (child) {
return (child != null ? child.type : void 0) === "h2";
});
if (!((ref = node.props) != null ? (ref1 = ref.className) != null ? ref1.includes("highlight-self") : void 0 : void 0)) {
node.props.className = node.props.className ? node.props.className + " highlight-self" : "highlight-self";
return;
}
}
});
return true;
};
css = `.highlight-self {
text-decoration: underline;
}`;
return HighlightSelf;
}.call(this);