Plugin

NoMosaic

Removes Discord image mosaic

Media Appearance Chat
index.ts
Download

Source

src/plugins/noMosaic/index.ts
1import { definePluginSettings } from "@api/Settings";
2import { Devs } from "@utils/constants";
3import definePlugin, { OptionType } from "@utils/types";
4
5const settings = definePluginSettings({
6 inlineVideo: {
7 description: "Play videos without carousel modal",
8 type: OptionType.BOOLEAN,
9 default: true,
10 restartNeeded: true
11 }
12});
13
14export default definePlugin({
15 name: "NoMosaic",
16 authors: [Devs.AutumnVN],
17 description: "Removes Discord image mosaic",
18 tags: ["Media", "Appearance", "Chat"],
19 searchTerms: ["image", "mosaic", "media"],
20
21 settings,
22
23 patches: [
24 {
25 find: '"PLAINTEXT_PREVIEW":"OTHER"',
26 replacement: {
27 match: /"IMAGE"===\i\|\|"VIDEO"===\i\|\|"CLIP"===\i/,
28 replace: "false"
29 }
30 },
31 {
32 find: "return{visualMediaItems:",
33 replacement: {
34 match: /return{visualMediaItems:.+?props:(\i)(?=.{0,20}?\1\.item\.uniqueId)/,
35 replace: '$&,useFullWidth:["IMAGE","VIDEO","CLIP"].includes($1.item?.type)?false:undefined'
36 }
37 },
38 {
39 find: "renderAttachments(",
40 predicate: () => settings.store.inlineVideo,
41 replacement: {
42 match: /url:(\i)\.url\}\);return /,
43 replace: "$&$1.content_type?.startsWith('image/')&&"
44 }
45 },
46 ]
47});
48