/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import "./style.css"; import { FFmpeg } from "@ffmpeg/ffmpeg"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { React } from "@webpack/common"; import { Channel } from "discord-types/general"; import { PickerContent, PickerHeader, PickerSidebar, Settings, Wrapper } from "./components"; import { getStickerPack, getStickerPackMetas } from "./stickers"; import { StickerPack, StickerPackMeta } from "./types"; import { cl, FFmpegStateContext, loadFFmpeg } from "./utils"; export default definePlugin({ name: "MoreStickers", description: "Adds sticker packs from other social media platforms. (e.g. LINE)", authors: [EquicordDevs.Leko, Devs.Arjix], options: { settings: { type: OptionType.COMPONENT, description: "Packs", component: Settings } }, patches: [ { find: "ChannelStickerPickerButton", replacement: [{ match: /(children:\(0,\i\.jsx\)\()(.{0,10})({innerClassName.{10,30}\.stickerButton)/, replace: "$1arguments[0]?.stickersType?$self.stickerButton:$2$3" }, { match: /(\i=)((\i\.useCallback\(\(\)=>\{\(.*?\)\().*?\.STICKER,(\i.{0,10}));/, replace: '$1arguments[0]?.stickersType?$3"stickers+",$4:$2;' }, { match: /(\i)=((\i)===\i\.\i\.STICKER)/, replace: "$1=arguments[0].stickersType?($3===arguments[0].stickersType):($2)" }] }, { 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+\"))" } }, { 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: /:null,((.{1,200})===.{1,30}\.STICKER&&\w+\?(\([^()]{1,10}\)).{1,15}?(\{.*?,onSelectSticker:.*?\})\):null)/, replace: ':null,$2==="stickers+"?$3($self.moreStickersComponent,$4):null,$1' } ] }, { find: '==="remove_text"', replacement: { match: /,\i\.insertText=\i=>{[\w ;]*?1===\i\.length&&.+?==="remove_text"/, replace: ",$self.textEditor=arguments[0]$&" } } ], stickerButton({ innerClassName, isActive, onClick }) { return ( ); }, moreStickersComponent({ channel, closePopout }: { channel: Channel, closePopout: () => void; }) { if (FFmpegStateContext === undefined) { return