53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/*
|
|
* Vencord, a Discord client mod
|
|
* Copyright (c) 2023 Vendicated and contributors
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
import { definePluginSettings } from "@api/Settings";
|
|
import { Devs } from "@utils/constants";
|
|
import definePlugin, { OptionType } from "@utils/types";
|
|
|
|
const settings = definePluginSettings({
|
|
inlineVideo: {
|
|
description: "Play videos without carousel modal",
|
|
type: OptionType.BOOLEAN,
|
|
default: true,
|
|
restartNeeded: true
|
|
}
|
|
});
|
|
|
|
export default definePlugin({
|
|
name: "NoMosaic",
|
|
authors: [Devs.AutumnVN],
|
|
description: "Removes Discord image mosaic",
|
|
tags: ["Media", "Appearance", "Chat"],
|
|
searchTerms: ["image", "mosaic", "media"],
|
|
|
|
settings,
|
|
|
|
patches: [
|
|
{
|
|
find: '"PLAINTEXT_PREVIEW":"OTHER"',
|
|
replacement: {
|
|
match: /"IMAGE"===\i\|\|"VIDEO"===\i\|\|"CLIP"===\i/,
|
|
replace: "false"
|
|
}
|
|
},
|
|
{
|
|
find: "return{visualMediaItems:",
|
|
replacement: {
|
|
match: /return{visualMediaItems:.+?props:(\i)(?=.{0,20}?\1\.item\.uniqueId)/,
|
|
replace: '$&,useFullWidth:["IMAGE","VIDEO","CLIP"].includes($1.item?.type)?false:undefined'
|
|
}
|
|
},
|
|
{
|
|
find: "renderAttachments(",
|
|
predicate: () => settings.store.inlineVideo,
|
|
replacement: {
|
|
match: /url:(\i)\.url\}\);return /,
|
|
replace: "$&$1.content_type?.startsWith('image/')&&"
|
|
}
|
|
},
|
|
]
|
|
});
|