Fix NitroBypass

This commit is contained in:
Vendicated 2022-10-01 17:04:57 +02:00
parent 967b101af1
commit be94dbbc6c
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -2,6 +2,7 @@ import { addPreSendListener, addPreEditListener, SendListener, removePreSendList
import { findByProps } from "../webpack"; import { findByProps } from "../webpack";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { Devs } from '../utils/constants'; import { Devs } from '../utils/constants';
import { UserStore } from '../webpack/common';
export default definePlugin({ export default definePlugin({
name: "NitroBypass", name: "NitroBypass",
@ -22,21 +23,33 @@ export default definePlugin({
}; };
}) })
}, },
{
find: "STREAM_FPS_OPTION.format",
replacement: {
match: /(userPremiumType|guildPremiumTier):.{0,10}TIER_\d,?/g,
replace: ""
}
}
], ],
get guildId() {
return window.location.href.split("channels/")[1].split("/")[0];
},
get canUseEmotes() {
return Boolean(UserStore.getCurrentUser().premiumType);
},
start() { start() {
if (this.canUseEmotes) {
console.info("[NitroBypass] Skipping start because you have nitro");
return;
}
const { getCustomEmojiById } = findByProps("getCustomEmojiById"); const { getCustomEmojiById } = findByProps("getCustomEmojiById");
// Remove any nitro requirements for any of the streaming settings.
findByProps("ApplicationStreamPresets")
.ApplicationStreamSettingRequirements
.forEach(x => {
delete x.userPremiumType;
delete x.guildPremiumTier;
});
this.preSend = addPreSendListener((_, messageObj) => { this.preSend = addPreSendListener((_, messageObj) => {
const guildId = window.location.href.split("channels/")[1].split("/")[0]; const guildId = this.guildId;
for (const emoji of messageObj.validNonShortcutEmojis) { for (const emoji of messageObj.validNonShortcutEmojis) {
if (!emoji.require_colons) continue; if (!emoji.require_colons) continue;
if (emoji.guildId === guildId && !emoji.animated) continue; if (emoji.guildId === guildId && !emoji.animated) continue;
@ -46,8 +59,9 @@ export default definePlugin({
messageObj.content = messageObj.content.replace(emojiString, ` ${url} `); messageObj.content = messageObj.content.replace(emojiString, ` ${url} `);
} }
}); });
this.preEdit = addPreEditListener((_, __, messageObj) => { this.preEdit = addPreEditListener((_, __, messageObj) => {
const guildId = window.location.href.split("channels/")[1].split("/")[0]; const guildId = this.guildId;
for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) { for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
const emoji = getCustomEmojiById(emojiId); const emoji = getCustomEmojiById(emojiId);