Update nitroBypass.ts (#132)

This commit is contained in:
jue131 2022-10-21 20:37:53 +09:00 committed by GitHub
parent ccf7f66a79
commit e93111fb67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,9 @@
import { addPreSendListener, addPreEditListener, removePreSendListener, removePreEditListener } from "../api/MessageEvents"; import { addPreSendListener, addPreEditListener, removePreSendListener, removePreEditListener } from "../api/MessageEvents";
import { findByProps } from "../webpack"; import { findByProps } from "../webpack";
import definePlugin from "../utils/types"; import definePlugin, { OptionType } from "../utils/types";
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import { UserStore } from "../webpack/common"; import { UserStore } from "../webpack/common";
import { Settings } from "../Vencord";
export default definePlugin({ export default definePlugin({
name: "NitroBypass", name: "NitroBypass",
@ -12,9 +13,21 @@ export default definePlugin({
patches: [ patches: [
{ {
find: "canUseAnimatedEmojis:function", find: "canUseAnimatedEmojis:function",
predicate: () => Settings.plugins.NitroBypass.enableEmojiBypass === true,
replacement: [ replacement: [
"canUseAnimatedEmojis", "canUseAnimatedEmojis",
"canUseEmojisEverywhere", "canUseEmojisEverywhere"
].map(func => {
return {
match: new RegExp(`${func}:function\\(.+?}`),
replace: `${func}:function (e) { return true; }`
};
})
},
{
find: "canUseAnimatedEmojis:function",
predicate: () => Settings.plugins.NitroBypass.enableStreamQualityBypass === true,
replacement: [
"canUseHighVideoUploadQuality", "canUseHighVideoUploadQuality",
"canStreamHighQuality", "canStreamHighQuality",
"canStreamMidQuality" "canStreamMidQuality"
@ -27,12 +40,27 @@ export default definePlugin({
}, },
{ {
find: "STREAM_FPS_OPTION.format", find: "STREAM_FPS_OPTION.format",
predicate: () => Settings.plugins.NitroBypass.enableStreamQualityBypass === true,
replacement: { replacement: {
match: /(userPremiumType|guildPremiumTier):.{0,10}TIER_\d,?/g, match: /(userPremiumType|guildPremiumTier):.{0,10}TIER_\d,?/g,
replace: "" replace: ""
} }
} }
], ],
options: {
enableEmojiBypass: {
description: "Allow sending fake emojis",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: true,
},
enableStreamQualityBypass: {
description: "Allow streaming in nitro quality",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: true,
}
},
get guildId() { get guildId() {
return window.location.href.split("channels/")[1].split("/")[0]; return window.location.href.split("channels/")[1].split("/")[0];
@ -43,6 +71,10 @@ export default definePlugin({
}, },
start() { start() {
if (!Settings.plugins.NitroBypass.enableEmojiBypass) {
return;
}
if (this.canUseEmotes) { if (this.canUseEmotes) {
console.info("[NitroBypass] Skipping start because you have nitro"); console.info("[NitroBypass] Skipping start because you have nitro");
return; return;