parent
ecab86b0ea
commit
44a163789d
6 changed files with 33 additions and 15 deletions
|
|
@ -80,15 +80,23 @@ export type ChatBarButtonFactory = (props: ChatBarProps & { isMainChat: boolean;
|
|||
const buttonFactories = new Map<string, ChatBarButtonFactory>();
|
||||
const logger = new Logger("ChatButtons");
|
||||
|
||||
export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) {
|
||||
export function _injectButtons(buttons: { key: string, node: ReactNode; }[], order: Record<string, number | null>, props: ChatBarProps) {
|
||||
if (props.disabled) return;
|
||||
|
||||
let anchorIndex = -100;
|
||||
let currentOrder = anchorIndex - 1;
|
||||
|
||||
for (const [key, Button] of buttonFactories) {
|
||||
buttons.push(
|
||||
<ErrorBoundary noop key={key} onError={e => logger.error(`Failed to render ${key}`, e.error)}>
|
||||
order[key] = anchorIndex;
|
||||
order.submit && (order.submit = ++currentOrder);
|
||||
anchorIndex = currentOrder + 1;
|
||||
|
||||
buttons.push({
|
||||
key,
|
||||
node: <ErrorBoundary noop key={key} onError={e => logger.error(`Failed to render ${key}`, e.error)}>
|
||||
<Button {...props} isMainChat={props.type.analyticsName === "normal"} />
|
||||
</ErrorBoundary>
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export default definePlugin({
|
|||
{
|
||||
// Gift button
|
||||
find: '"sticker")',
|
||||
replacement: { match: /&&\i\.push\(\([^&]*?,"gift"\)\)/, replace: "", },
|
||||
replacement: { match: /&&\i\.push\(\{[^&]*?,"gift"\)\}\)/, replace: "", },
|
||||
predicate: () => settings.store.gift,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ export default definePlugin({
|
|||
{
|
||||
find: '"sticker")',
|
||||
replacement: {
|
||||
match: /(\.buttons,children:)(.+?)\}/,
|
||||
match: /(\.buttons,.{0,50}children:)(.+?)\}/,
|
||||
replace: "$1$self.wrapChatBarChildren($2)}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export default definePlugin({
|
|||
{
|
||||
find: '"sticker")',
|
||||
replacement: {
|
||||
match: /(.buttons,children:)(.+?)\}/,
|
||||
match: /(.buttons,.{0,50}children:)(.+?)\}/,
|
||||
replace: "$1$self.buttonsInner($2)}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,17 +48,27 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: ".gifts)",
|
||||
replacement: {
|
||||
match: /(?<=,.{0,5}\(null==\(\i=\i\.stickers\)\?void 0.*?(\i)\.push\((\(0,\i\.jsx\))\((.+?),{disabled:\i,type:(\i)},"sticker"\)\)\))/,
|
||||
replace: ",arguments[0].type?.submit?.button&&$1.push($2($3,{disabled:!arguments[0].type?.submit?.button,type:$4,stickersType:\"stickers+\"},\"stickers+\"))"
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<="submit"\)\}\);)(?=.{0,50}null!=(\i))/,
|
||||
replace: '$1["stickers+"]=3;'
|
||||
},
|
||||
{
|
||||
match: /(?<=,.{0,5}\(null==\(\i=\i\.stickers\)\?void 0.*?(\i)\.push\(\{.{0,15}node:(.{0,15}{disabled:\i,type:\i)},"sticker"\)\}\))/,
|
||||
replace: ",arguments[0].type?.submit?.button&&$1.push({key:\"stickers+\",node:$2,stickersType:\"stickers+\"},\"stickers+\")})"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: "#{intl::EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL}",
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=null,(\i)\?(\(.*?\))\((\i),{.{0,128},isActive:(\i)===.{0,200},children:(\i\.intl\.string\(.*?\))\}\)\}\):null,)/s,
|
||||
replace: '$1?$2($3,{id:"stickers+-picker-tab","aria-controls":"more-stickers-picker-tab-panel","aria-selected":$4==="stickers+",isActive:$4==="stickers+",autoFocus:true,viewType:"stickers+",children:$5+"+"}):null,'
|
||||
match: /(?<=(\i)\?(\(.{0,15}\))\((\i),\{.{0,150}(\i)===\i\.\i\.STICKER,.{0,150}children:(.{0,30}\.stickersNavItem,children:.{0,25})\}\)\}\):null)/,
|
||||
replace: ',vcStickers=$1?$2($3,{id:"stickers+-picker-tab","aria-controls":"more-stickers-picker-tab-panel","aria-selected":$4==="stickers+",isActive:$4==="stickers+",autoFocus:true,viewType:"stickers+",children:$5+"+"})}):null'
|
||||
},
|
||||
{
|
||||
match: /children:\[\i,\i(?=.{0,5}\}\))/g,
|
||||
replace: "$&,vcStickers"
|
||||
},
|
||||
{
|
||||
match: /:null,((.{1,200})===.{1,30}\.STICKER&&\w+\?(\([^()]{1,10}\)).{1,15}?(\{.*?,onSelectSticker:.*?\})\):null)/,
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ export default definePlugin({
|
|||
{
|
||||
find: '"sticker")',
|
||||
replacement: {
|
||||
match: /return\(\i\.\i\|\|(?=\(.+?(\i)\.push)/,
|
||||
replace: "$&(Vencord.Api.ChatButtons._injectButtons($1,arguments[0]),false)||"
|
||||
match: /(?=\i&&(\i)\.push.{0,15}"submit".{0,100}?null!=(\i))/,
|
||||
replace: "Vencord.Api.ChatButtons._injectButtons($1,$2,arguments[0]),"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue