This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
73 lines (57 loc) · 2.03 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
71
72
73
const { Plugin } = require('powercord/entities');
const { getModule } = require('powercord/webpack');
const { inject, uninject } = require('powercord/injector');
const Settings = require('./components/settings.jsx');
module.exports = class NitroBypass extends Plugin {
async startPlugin() {
powercord.api.settings.registerSettings(this.entityID, {
category: this.entityID,
label: 'Nitro Bypass',
render: Settings,
});
const message = await getModule(['sendMessage', 'editMessage']);
const currentUser = await getModule(['getCurrentUser']);
this.getGuildId = (await getModule(['getLastSelectedGuildId'])).getGuildId;
// spoof client side premium
let tries = 1;
let intervalId = setInterval(() => {
if (++tries > 5) clearInterval(intervalId);
const user = currentUser.getCurrentUser();
if (!user) return;
user.premiumType = 2;
clearInterval(intervalId);
}, 1000);
const emojiReplacePatch = this.emojiReplacePatch.bind(this);
inject('replace-on-send', message, 'sendMessage', emojiReplacePatch, true);
}
emojiReplacePatch(args) {
const message = args[1];
const emojis = message.validNonShortcutEmojis;
const guildId = this.getGuildId();
emojis.forEach((emoji) => {
// skip discord emojis
if (!emoji.require_colons) return;
// skip available emojis
if (
!this.settings.get('spoofAvailableEmojis', false) &&
emoji.guildId === guildId && !emoji.animated
)
return;
// create the emoji string which we will replace
const emojiString = `<${emoji.animated ? 'a' : ''}:${emoji.originalName || emoji.name}:${
emoji.id
}>`;
let url = emoji.url;
// change the size of the emoji in the url
const emojiSize = this.settings.get('size', 48);
url = url.replace(/\?size=[0-9]+/, `?size=${emojiSize}`);
// replace the message containing the emoji with the url
message.content = message.content.replace(emojiString, url);
});
return args;
}
pluginWillUnload() {
powercord.api.settings.unregisterSettings(this.entityID);
uninject('replace-on-send');
}
};