Skip to content

Commit

Permalink
MoreStickers: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoOwO committed Oct 25, 2023
1 parent 245d64c commit fa9cb4b
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/plugins/moreStickers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,43 @@ export default definePlugin({

patches: [
{
find: "().stickerIcon,",
find: ".stickerIcon,",
replacement: [{
match: /(children:\(0,\w\.jsx\)\()(\w{2})(,{innerClassName.{20,30}\.stickerButton)/,
match: /(children:\(0,\w\.jsx\)\()([\w.]+?)(,{innerClassName.{10,30}\.stickerButton)/,
replace: (_, head, button, tail) => {
const isMoreStickers = "arguments[0]?.stickersType";
return `${head}${isMoreStickers}?$self.stickerButton:${button}${tail}`;
}
}, {
match: /null==\(null===\(\w=\w\.stickers\)\|\|void 0.*?(\w)\.push\((\(0,\w\.jsx\))\((\w+),{disabled:\w,type:(\w)},"sticker"\)\)/,
replace: (m, _, jsx, compo, type) => {
const c = "arguments[0].type";
return `${m};${c}?.submit?.button&&${_}.push(${jsx}(${compo},{disabled:!${c}?.submit?.button,type:${type},stickersType:"stickers+"},"stickers+"))`;
}
}, {
match: /(var \w=)(\w\.useCallback\(\(function\(\)\{\(0,\w+\.\w+\)\([\w\.]*?\.STICKER,.*?);/,
match: /(let \w=)(\w\.useCallback\(\(\)=>\{\(0,\w+\.\w+\)\([\w\.]*?\.STICKER,.*?);/,
replace: (_, decl, cb) => {
const newCb = cb.replace(/(?<=function\(\)\{\(.*?\)\().+?\.STICKER/, "\"stickers+\"");
const newCb = cb.replace(/(?<=\(\)=>\{\(.*?\)\().+?\.STICKER/, "\"stickers+\"");
return `${decl}arguments[0]?.stickersType?${newCb}:${cb};`;
}
}, {
match: /(\w)=((\w)===\w+\.\w+\.STICKER)/,
match: /(\w)=((\w)===\w+?\.\w+?\.STICKER)/,
replace: (_, isActive, isStickerTab, currentTab) => {
const c = "arguments[0].stickersType";
return `${isActive}=${c}?(${currentTab}===${c}):(${isStickerTab})`;
}
}]
},
{
find: '"ChannelTextAreaButtons"',
replacement: {
match: /,\(null===\(\w=\w\.stickers\)\|\|void 0.*?(\w)\.push\((\(0,\w\.jsx\))\((.+?),{disabled:\w,type:(\w)},"sticker"\)\)/,
replace: (m, _, jsx, compo, type) => {
const c = "arguments[0].type";
return `${m},${c}?.submit?.button&&${_}.push(${jsx}(${compo},{disabled:!${c}?.submit?.button,type:${type},stickersType:"stickers+"},"stickers+"))`;
}
}
},
{
find: ".Messages.EXPRESSION_PICKER_GIF",
replacement: {
match: /role:"tablist",.{10,20}\.Messages\.EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL,children:(\[.*?\)\]}\)}\):null,)(.*?closePopout:\w.*?:null)/s,
match: /role:"tablist",.+?\.Messages\.EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL,children:(\[.*?\)\]}\)}\):null,)(.*?closePopout:\w.*?:null)/s,
replace: m => {
const stickerTabRegex = /(\w)\?(\(.+?\))\((.{1,2}),.*?isActive:(\w)==.*?children:(.{1,10}Messages.EXPRESSION_PICKER_STICKER).*?:null/s;
const stickerTabRegex = /(\w+)\?(\(.+?\))\((.{1,2}),.*?isActive:(\w)==.*?children:(.{1,10}Messages.EXPRESSION_PICKER_STICKER).*?:null/s;
const res = m.replace(stickerTabRegex, (_m, canUseStickers, jsx, tabHeaderComp, currentTab, stickerText) => {
const isActive = `${currentTab}==="stickers+"`;
return (
Expand All @@ -90,17 +94,17 @@ export default definePlugin({
);
});

return res.replace(/:null,((\w)===.*?\.STICKER&&\w\?(\(.*?\)).*?(\{.*?,onSelectSticker:.*?\})\):null)/s, (_, _m, currentTab, jsx, props) => {
return res.replace(/:null,((\w)===.*?\.STICKER&&\w+\?(\(.*?\)).*?(\{.*?,onSelectSticker:.*?\})\):null)/s, (_, _m, currentTab, jsx, props) => {
return `:null,${currentTab}==="stickers+"?${jsx}($self.moreStickersComponent,${props}):null,${_m}`;
});
}
}
},
{
find: ".insertText=function",
find: '==="remove_text"',
replacement: {
match: /;\w\.insertText=function\(\w\){1===\w\.length&&"remove_text"=/,
replace: ";$self.textEditor=arguments[0]$&"
match: /,\w\.insertText=\w=>{[\w ;]*?1===\w\.length&&.+?==="remove_text"/,
replace: ",$self.textEditor=arguments[0]$&"
}
}
],
Expand Down

0 comments on commit fa9cb4b

Please sign in to comment.