Skip to content

Commit

Permalink
Added switches to disable emoji/stickers spoof
Browse files Browse the repository at this point in the history
  • Loading branch information
cafeed28 committed Jun 18, 2023
1 parent 0432b6f commit 0276125
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 18 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"discordID": "942752356595023874",
"github": "cafeed28"
},
"version": "2.1.6",
"version": "2.1.7",
"updater": {
"type": "store",
"id": "com.cafeed28.NitroSpoof"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "replugged-nitrospoof",
"version": "2.1.6",
"version": "2.1.7",
"description": "Use some Nitro features without wasting your money!",
"engines": {
"node": ">=14.0.0"
Expand Down
8 changes: 8 additions & 0 deletions src/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export function Settings() {
return (
<div>
<Category title="Emoji" note="Emoji spoofer settings">
<SwitchItem {...util.useSetting(config, "emojiSpoof", true)} hideBorder>
Enable emoji spoof
</SwitchItem>

<SwitchItem {...util.useSetting(config, "emojiHideLinks", false)} hideBorder>
Hide emoji links using Discord spoiler bug (199 trailing spoilers)
</SwitchItem>
Expand All @@ -30,6 +34,10 @@ export function Settings() {
</Category>

<Category title="Sticker" note="Sticker spoofer settings">
<SwitchItem {...util.useSetting(config, "stickerSpoof", true)} hideBorder>
Enable sticker spoof
</SwitchItem>

<FormItem title="Sticker Size" style={{ marginBottom: 20 }}>
<div style={{ marginTop: 20 }}>
<Slider
Expand Down
49 changes: 37 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,48 @@ export async function start(): Promise<void> {
users.addChangeListener(userChanged);

injector.after(messageParser, "parse", (_, message) => {
if (ready) spoofEmojis(message);
if (ready && config.get("emojiSpoof")) spoofEmojis(message);
return message;
});

// Chat emoji picker
injector.instead(emojiInfo, "isEmojiFiltered", () => false);
injector.instead(emojiInfo, "isEmojiDisabled", () => false);
injector.instead(emojiInfo, "isEmojiPremiumLocked", () => false);
injector.instead(emojiInfo, "isEmojiFiltered", (args, orig) => {
if (!config.get("emojiSpoof")) return orig(...args);
return false;
});

injector.instead(emojiInfo, "isEmojiDisabled", (args, orig) => {
if (!config.get("emojiSpoof")) return orig(...args);
return false;
});

injector.instead(emojiInfo, "isEmojiPremiumLocked", (args, orig) => {
if (!config.get("emojiSpoof")) return orig(...args);
return false;
});

// Emoji picker tint
injector.instead(emojiInfo, "getEmojiUnavailableReason", () => null);
injector.instead(emojiInfo, "getEmojiUnavailableReason", (args, orig) => {
if (!config.get("emojiSpoof")) return orig(...args);
return null;
});

// Stickers
injector.instead(stickerInfo, shouldAttachSticker, () => true);
injector.instead(stickerSendability, isSendableSticker, () => true);
injector.instead(stickerInfo, shouldAttachSticker, (args, orig) => {
if (!config.get("stickerSpoof")) return orig(args);
return true;
});

injector.instead(stickerSendability, isSendableSticker, (args, orig) => {
if (!config.get("stickerSpoof")) return orig(args);
return true;
});

injector.instead(stickerPreview, addStickerPreview, async (args, orig) => {
if (!config.get("stickerSpoof")) return orig(args);

const [channelId, sticker, d] = args;

injector.instead(stickerPreview, addStickerPreview, async ([channelId, sticker, d], orig) => {
const debugMode = config.get("debugMode");
if (debugMode) {
logger.log("ready:", ready);
Expand All @@ -68,13 +93,13 @@ export async function start(): Promise<void> {
});

// Stream quality
injector.instead(premiumInfo, "canStreamHighQuality", (_, orig) => {
if (!config.get("streamQualityEnable")) return orig(_);
injector.instead(premiumInfo, "canStreamHighQuality", (args, orig) => {
if (!config.get("streamQualityEnable")) return orig(args);
return true;
});

injector.instead(premiumInfo, "canStreamMidQuality", (_, orig) => {
if (!config.get("streamQualityEnable")) return orig(_);
injector.instead(premiumInfo, "canStreamMidQuality", (args, orig) => {
if (!config.get("streamQualityEnable")) return orig(args);
return true;
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { User } from "discord-types/general";
import { Config, PremiumType, UserFetchResponse } from "./types";

export const config = await settings.init<Config>("com.cafeed28.NitroSpoof", {
emojiSpoof: true,
emojiSize: 48,
emojiHideLinks: false,

stickerSpoof: true,
stickerSize: 160,

streamQualityEnable: false,
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export type Config = {
emojiSpoof?: boolean;
emojiSize?: number;
emojiHideLinks?: boolean;

stickerSpoof?: boolean;
stickerSize?: number;

streamQualityEnable?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions src/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type { AnyFunction, ObjectExports } from "replugged/dist/types";
import type { Attachment, OutgoingMessage, UserFetchResponse } from "./types";

type EmojiInfo = {
isEmojiFiltered: () => boolean;
isEmojiDisabled: () => boolean;
isEmojiPremiumLocked: () => boolean;
getEmojiUnavailableReason: () => null;
isEmojiFiltered: (...args: unknown[]) => boolean;
isEmojiDisabled: (...args: unknown[]) => boolean;
isEmojiPremiumLocked: (...args: unknown[]) => boolean;
getEmojiUnavailableReason: (...args: unknown[]) => null;
};
export const emojiInfo = await waitForProps<string, EmojiInfo>("getEmojiUnavailableReason");

Expand Down

0 comments on commit 0276125

Please sign in to comment.