Skip to content

Commit

Permalink
HideGiftButton: spoof hide gift state
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed Jul 4, 2024
1 parent ef38568 commit 9f91cce
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugins/HideGiftButton/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { findByName } from "@vendetta/metro";
import { findByName, findByProps } from "@vendetta/metro";
import { after } from "@vendetta/patcher";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { findInReactTree } from "@vendetta/utils";

const ChatInput = findByName("ChatInput");
const ChatInputGift = findByProps("ChatInput");
const ChatInputThreads = findByName("ChatInput");

let unpatch: () => boolean;
let unpatchGift: () => boolean;
let unpatchThreads: () => boolean;

export default {
onLoad() {
const blockList = ["ic_thread_normal_24px", "ic_gift"].map(n => getAssetIDByName(n));
unpatch = after("render", ChatInput.prototype, (_, ret) => {
unpatchGift = after("render", ChatInputGift.ChatInput.prototype, (_, ret) => {
const states = findInReactTree(ret, t =>
typeof t.props?.hideGiftButton === "boolean"
);
states.props.hideGiftButton = true;
});
unpatchThreads = after("render", ChatInputThreads.prototype, (_, ret) => {
const input = findInReactTree(ret, t => "forceAnimateButtons" in t.props && t.props.actions);
input.props.actions = input.props.actions.filter(a => !blockList.includes(a.source));
});
},
onUnload: unpatch
onUnload: unpatchGift, unpatchThreads
};

0 comments on commit 9f91cce

Please sign in to comment.