-
Notifications
You must be signed in to change notification settings - Fork 357
/
BetterEmoteSizes.plugin.js
215 lines (191 loc) · 7.99 KB
/
BetterEmoteSizes.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//META{"name":"BetterEmoteSizes","website":"https://metalloriff.github.io/toms-discord-stuff/","source":"https://github.com/Metalloriff/BetterDiscordPlugins/blob/master/BetterEmoteSizes.plugin.js"}*//
class BetterEmoteSizes {
getName() { return "Emote Zoom"; }
getDescription() { return "Increases the size of emojis, emotes, and reactions upon hovering over them and allows you to change their default sizes."; }
getVersion() { return "2.4.17"; }
getAuthor() { return "Metalloriff"; }
get settingFields() {
return {
alterSmall: { label: "Affect small emojis", type: "bool" },
smallSize: { label: "Default small emoji size (px)", type: "number" },
alterLarge: { label: "Affect large emojis", type: "bool" },
largeSize: { label: "Default large emoji size (px)", type: "number" },
alterBD: { label: "Affect small BetterDiscord emotes", type: "bool" },
bdSize: { label: "Default small BetterDiscord emote size (px)", type: "number" },
alterLargeBD: { label: "Affect large BetterDiscord emotes", type: "bool" },
largeBdSize: { label: "Default large BetterDiscord emote size (px)", type: "number" },
alterReactions: { label: "Affect reactions", type: "bool" },
reactionSize: { label: "Default reaction size (px)", type: "number" },
hoverSize: { label: "Emoji and BetterDiscord emote hover size multiplier", type: "number" },
reactionHoverSize: { label: "Reaction hover size multiplier", type: "number" },
transitionSpeed: { label: "Transition speed (seconds)", type: "number" },
delayAmount: { label: "Delay amount (seconds)", type: "number" },
equal: { label: "Small and large emote zoom to equal", type: "bool" }
};
}
get defaultSettings() {
return {
displayUpdateNotes: true,
alterSmall: true,
smallSize: 22,
alterLarge: true,
largeSize: 32,
alterBD: true,
bdSize: 28,
alterLargeBD: true,
largeBdSize: 32,
alterReactions: true,
reactionSize: 16,
hoverSize: 3,
transitionSpeed: 0.5,
delayAmount: 0,
reactionHoverSize: 2,
equal: false
};
}
getSettingsPanel() {
return NeatoLib.Settings.createPanel(this);
}
saveSettings() {
NeatoLib.Settings.save(this);
this.update();
}
load() {}
start() {
const libLoadedEvent = () => {
try{ this.onLibLoaded(); }
catch(err) { console.error(this.getName(), "fatal error, plugin could not be started!", err); try { this.stop(); } catch(err) { console.error(this.getName() + ".stop()", err); } }
};
let lib = document.getElementById("NeatoBurritoLibrary");
if (!lib) {
lib = document.createElement("script");
lib.id = "NeatoBurritoLibrary";
lib.type = "text/javascript";
lib.src = "https://rawgit.com/Metalloriff/BetterDiscordPlugins/master/Lib/NeatoBurritoLibrary.js";
document.head.appendChild(lib);
}
this.forceLoadTimeout = setTimeout(libLoadedEvent, 30000);
if (typeof window.NeatoLib !== "undefined") libLoadedEvent();
else lib.addEventListener("load", libLoadedEvent);
}
onLibLoaded() {
this.settings = NeatoLib.Settings.load(this);
NeatoLib.Updates.check(this, "https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/BetterEmoteSizes.plugin.js");
if (!NeatoLib.hasRequiredLibVersion(this, "0.7.19")) return;
this.update();
NeatoLib.Events.onPluginLoaded(this);
}
update() {
const markup = NeatoLib.getClass("markup"), markupRtl = NeatoLib.getClass("markupRtl"), messageGroup = NeatoLib.getClass("cozyMessage"), message = NeatoLib.getClass("message"), reaction = NeatoLib.getClass("reaction"), reactionMe = NeatoLib.getClass("reactionMe");
if (this.style) this.style.destroy();
this.style = NeatoLib.injectCSS(`.${messageGroup} { overflow: visible; }`);
if (this.settings.alterSmall) {
this.style.append(`
#app-mount .${markup} > .emoji:not(.jumboable),
#app-mount .${markupRtl} > .emoji:not(.jumboable) {
height: ${this.settings.smallSize}px;
width: auto;
transform: scale(1);
transition: transform ${this.settings.transitionSpeed}s;
transition-delay: 0s;
}
#app-mount .${markup} > .emoji:not(.jumboable):hover,
#app-mount .${markupRtl} > .emoji:not(.jumboable):hover {
transform: scale(${this.settings.equal ? ((this.settings.largeSize / this.settings.smallSize) * this.settings.hoverSize) : this.settings.hoverSize});
position: relative;
z-index: 1;
transition-delay: ${this.settings.delayAmount}s;
}
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .${markup} .emoji:not(.jumboable):hover,
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .${markupRtl} .emoji:not(.jumboable):hover {
transform: scale(${this.settings.equal ? ((this.settings.largeSize / this.settings.smallSize) * this.settings.hoverSize) : this.settings.hoverSize}) translateY(-35%);
}
`);
}
if (this.settings.alterLarge) {
this.style.append(`
#app-mount .${markup} > .emoji.jumboable,
#app-mount .${markupRtl} > .emoji.jumboable {
height: ${this.settings.largeSize}px;
width: auto;
transform: scale(1);
transition: transform ${this.settings.transitionSpeed}s;
transition-delay: 0s;
}
#app-mount .${markup} > .emoji.jumboable:hover,
#app-mount .${markupRtl} > .emoji.jumboable:hover {
transform: scale(${this.settings.hoverSize});
position: relative;
z-index: 1;
transition-delay: ${this.settings.delayAmount}s;
}
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .${markup} .emoji.jumboable:hover,
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .${markupRtl} .emoji.jumboable:hover {
transform: scale(${this.settings.hoverSize}) translateY(-35%);
}
`);
}
if (this.settings.alterBD) {
this.style.append(`
#app-mount .emote:not(.jumboable) {
height: ${this.settings.bdSize}px;
width: auto;
max-height: ${this.settings.bdSize}px !important;
transform: scale(1);
transition: transform ${this.settings.transitionSpeed}s;
transition-delay: 0s;
}
#app-mount .emote:not(.emoteshake):not(.emoteshake2):not(.emoteshake3):not(.jumboable):hover {
transform: scale(${this.settings.hoverSize});
position: relative;
z-index: 1;
transition-delay: ${this.settings.delayAmount}s;
}
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .emote:not(.emoteshake):not(.emoteshake2):not(.emoteshake3):not(.jumboable):hover {
transform: scale(${this.settings.hoverSize}) translateY(-35%);
}
`);
}
if (this.settings.alterLargeBD) {
this.style.append(`
#app-mount .emote.jumboable {
height: ${this.settings.largeBdSize}px;
width: auto;
max-height: ${this.settings.largeBdSize}px !important;
transform: scale(1);
transition: transform ${this.settings.transitionSpeed}s;
transition-delay: 0s;
}
#app-mount .emote.jumboable:not(.emoteshake):not(.emoteshake2):not(.emoteshake3):hover {
transform: scale(${this.settings.hoverSize});
position: relative;
z-index: 1;
transition-delay: ${this.settings.delayAmount}s;
}
#app-mount .${messageGroup}:last-child .${message}:nth-last-child(2) .emote.jumboable:not(.emoteshake2):not(.emoteshake3):hover {
transform: scale(${this.settings.hoverSize}) translateY(-35%);
}
`);
}
if (this.settings.alterReactions) {
this.style.append(`
#app-mount .${reaction} .emoji, .${reaction}.${reactionMe} .emoji {
height: ${this.settings.reactionSize}px;
width: auto;
}
#app-mount .${reaction} {
transition: transform ${this.settings.transitionSpeed}s;
transition-delay: 0s;
}
#app-mount .${reaction}:hover {
transform: scale(${this.settings.reactionHoverSize}) !important;
z-index: 1000;
transition-delay: ${this.settings.delayAmount}s;
}
`);
}
}
stop() {
if (this.style) this.style.destroy();
}
}