2022-11-13 22:13:32 +00:00
|
|
|
/*
|
|
|
|
* Vencord, a modification for Discord's desktop app
|
|
|
|
* Copyright (c) 2022 Vendicated and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-12-25 19:47:35 +00:00
|
|
|
import "./messageLogger.css";
|
|
|
|
|
2024-06-07 21:28:17 +00:00
|
|
|
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
|
|
|
import { updateMessage } from "@api/MessageUpdater";
|
2023-05-05 23:36:00 +00:00
|
|
|
import { Settings } from "@api/Settings";
|
2023-02-09 18:36:30 +00:00
|
|
|
import { disableStyle, enableStyle } from "@api/Styles";
|
2022-11-28 12:37:55 +00:00
|
|
|
import ErrorBoundary from "@components/ErrorBoundary";
|
|
|
|
import { Devs } from "@utils/constants";
|
2023-05-05 23:36:00 +00:00
|
|
|
import { Logger } from "@utils/Logger";
|
2022-11-28 12:37:55 +00:00
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
2023-03-25 02:37:29 +00:00
|
|
|
import { findByPropsLazy } from "@webpack";
|
2024-06-07 21:28:17 +00:00
|
|
|
import { ChannelStore, FluxDispatcher, i18n, Menu, MessageStore, Parser, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
|
|
|
import { Message } from "discord-types/general";
|
2022-11-13 22:13:32 +00:00
|
|
|
|
2023-02-09 18:36:30 +00:00
|
|
|
import overlayStyle from "./deleteStyleOverlay.css?managed";
|
|
|
|
import textStyle from "./deleteStyleText.css?managed";
|
|
|
|
|
2024-06-07 21:28:17 +00:00
|
|
|
interface MLMessage extends Message {
|
|
|
|
deleted?: boolean;
|
|
|
|
editHistory?: { timestamp: Date; content: string; }[];
|
|
|
|
}
|
|
|
|
|
2023-03-18 03:37:55 +00:00
|
|
|
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
|
|
|
|
2023-02-09 18:36:30 +00:00
|
|
|
function addDeleteStyle() {
|
2022-11-13 22:13:32 +00:00
|
|
|
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
2023-02-09 18:36:30 +00:00
|
|
|
enableStyle(textStyle);
|
|
|
|
disableStyle(overlayStyle);
|
2022-11-13 22:13:32 +00:00
|
|
|
} else {
|
2023-02-09 18:36:30 +00:00
|
|
|
disableStyle(textStyle);
|
|
|
|
enableStyle(overlayStyle);
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-16 23:27:25 +00:00
|
|
|
const REMOVE_HISTORY_ID = "ml-remove-history";
|
|
|
|
const TOGGLE_DELETE_STYLE_ID = "ml-toggle-style";
|
2024-03-07 10:06:24 +00:00
|
|
|
const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) => {
|
2023-03-25 00:55:40 +00:00
|
|
|
const { message } = props;
|
|
|
|
const { deleted, editHistory, id, channel_id } = message;
|
|
|
|
|
|
|
|
if (!deleted && !editHistory?.length) return;
|
|
|
|
|
2023-04-28 02:23:42 +00:00
|
|
|
toggle: {
|
|
|
|
if (!deleted) break toggle;
|
|
|
|
|
|
|
|
const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`);
|
|
|
|
if (!domElement) break toggle;
|
|
|
|
|
|
|
|
children.push((
|
|
|
|
<Menu.MenuItem
|
|
|
|
id={TOGGLE_DELETE_STYLE_ID}
|
|
|
|
key={TOGGLE_DELETE_STYLE_ID}
|
|
|
|
label="Toggle Deleted Highlight"
|
|
|
|
action={() => domElement.classList.toggle("messagelogger-deleted")}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-03-25 00:55:40 +00:00
|
|
|
children.push((
|
|
|
|
<Menu.MenuItem
|
2023-04-16 23:27:25 +00:00
|
|
|
id={REMOVE_HISTORY_ID}
|
|
|
|
key={REMOVE_HISTORY_ID}
|
2023-03-25 00:55:40 +00:00
|
|
|
label="Remove Message History"
|
2023-04-28 02:23:42 +00:00
|
|
|
color="danger"
|
2023-03-25 00:55:40 +00:00
|
|
|
action={() => {
|
2023-04-16 23:27:25 +00:00
|
|
|
if (deleted) {
|
2023-03-25 00:55:40 +00:00
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "MESSAGE_DELETE",
|
|
|
|
channelId: channel_id,
|
|
|
|
id,
|
|
|
|
mlDeleted: true
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
message.editHistory = [];
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
2024-06-07 21:28:17 +00:00
|
|
|
const patchChannelContextMenu: NavContextMenuPatchCallback = (children, { channel }) => {
|
|
|
|
const messages = MessageStore.getMessages(channel?.id) as MLMessage[];
|
|
|
|
if (!messages?.some(msg => msg.deleted || msg.editHistory?.length)) return;
|
|
|
|
|
|
|
|
const group = findGroupChildrenByChildId("mark-channel-read", children) ?? children;
|
|
|
|
group.push(
|
|
|
|
<Menu.MenuItem
|
|
|
|
id="vc-ml-clear-channel"
|
|
|
|
label="Clear Message Log"
|
|
|
|
color="danger"
|
|
|
|
action={() => {
|
|
|
|
messages.forEach(msg => {
|
|
|
|
if (msg.deleted)
|
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "MESSAGE_DELETE",
|
|
|
|
channelId: channel.id,
|
|
|
|
id: msg.id,
|
|
|
|
mlDeleted: true
|
|
|
|
});
|
|
|
|
else
|
|
|
|
updateMessage(channel.id, msg.id, {
|
|
|
|
editHistory: []
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-11-13 22:13:32 +00:00
|
|
|
export default definePlugin({
|
|
|
|
name: "MessageLogger",
|
|
|
|
description: "Temporarily logs deleted and edited messages.",
|
2024-06-07 21:28:17 +00:00
|
|
|
authors: [Devs.rushii, Devs.Ven, Devs.AutumnVN, Devs.Nickyux],
|
|
|
|
dependencies: ["MessageUpdaterAPI"],
|
2022-11-13 22:13:32 +00:00
|
|
|
|
2024-03-07 10:06:24 +00:00
|
|
|
contextMenus: {
|
2024-06-07 21:28:17 +00:00
|
|
|
"message": patchMessageContextMenu,
|
|
|
|
"channel-context": patchChannelContextMenu,
|
|
|
|
"user-context": patchChannelContextMenu,
|
|
|
|
"gdm-context": patchChannelContextMenu
|
2022-11-13 22:13:32 +00:00
|
|
|
},
|
|
|
|
|
2024-03-07 10:06:24 +00:00
|
|
|
start() {
|
|
|
|
addDeleteStyle();
|
2022-11-13 22:13:32 +00:00
|
|
|
},
|
|
|
|
|
2024-06-07 21:28:17 +00:00
|
|
|
renderEdits: ErrorBoundary.wrap(({ message: { id: messageId, channel_id: channelId } }: { message: Message; }) => {
|
|
|
|
const message = useStateFromStores(
|
|
|
|
[MessageStore],
|
|
|
|
() => MessageStore.getMessage(channelId, messageId) as MLMessage,
|
|
|
|
null,
|
2024-06-08 02:15:29 +00:00
|
|
|
(oldMsg, newMsg) => oldMsg?.editHistory === newMsg?.editHistory
|
2024-06-07 21:28:17 +00:00
|
|
|
);
|
|
|
|
|
2022-11-13 22:13:32 +00:00
|
|
|
return (
|
2024-06-07 21:28:17 +00:00
|
|
|
<>
|
|
|
|
{message.editHistory?.map(edit => (
|
|
|
|
<div className="messagelogger-edited">
|
|
|
|
{Parser.parse(edit.content)}
|
|
|
|
<Timestamp
|
|
|
|
timestamp={edit.timestamp}
|
|
|
|
isEdited={true}
|
|
|
|
isInline={false}
|
|
|
|
>
|
|
|
|
<span className={styles.edited}>{" "}({i18n.Messages.MESSAGE_EDITED})</span>
|
|
|
|
</Timestamp>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</>
|
2022-11-13 22:13:32 +00:00
|
|
|
);
|
2024-06-07 21:28:17 +00:00
|
|
|
}, { noop: true }),
|
2022-11-13 22:13:32 +00:00
|
|
|
|
|
|
|
makeEdit(newMessage: any, oldMessage: any): any {
|
|
|
|
return {
|
2024-02-14 18:07:51 +00:00
|
|
|
timestamp: new Date(newMessage.edited_timestamp),
|
2022-11-13 22:13:32 +00:00
|
|
|
content: oldMessage.content
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
options: {
|
|
|
|
deleteStyle: {
|
|
|
|
type: OptionType.SELECT,
|
|
|
|
description: "The style of deleted messages",
|
|
|
|
default: "text",
|
|
|
|
options: [
|
|
|
|
{ label: "Red text", value: "text", default: true },
|
|
|
|
{ label: "Red overlay", value: "overlay" }
|
|
|
|
],
|
2023-02-09 18:36:30 +00:00
|
|
|
onChange: () => addDeleteStyle()
|
2022-11-14 15:22:50 +00:00
|
|
|
},
|
2024-03-16 02:27:59 +00:00
|
|
|
logDeletes: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Whether to log deleted messages",
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
logEdits: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Whether to log edited messages",
|
|
|
|
default: true,
|
|
|
|
},
|
2022-11-14 15:22:50 +00:00
|
|
|
ignoreBots: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Whether to ignore messages by bots",
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
ignoreSelf: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Whether to ignore messages by yourself",
|
|
|
|
default: false
|
2023-06-16 17:35:35 +00:00
|
|
|
},
|
|
|
|
ignoreUsers: {
|
|
|
|
type: OptionType.STRING,
|
|
|
|
description: "Comma-separated list of user IDs to ignore",
|
|
|
|
default: ""
|
2023-07-14 16:21:29 +00:00
|
|
|
},
|
|
|
|
ignoreChannels: {
|
|
|
|
type: OptionType.STRING,
|
|
|
|
description: "Comma-separated list of channel IDs to ignore",
|
|
|
|
default: ""
|
|
|
|
},
|
|
|
|
ignoreGuilds: {
|
|
|
|
type: OptionType.STRING,
|
|
|
|
description: "Comma-separated list of guild IDs to ignore",
|
|
|
|
default: ""
|
|
|
|
},
|
2022-11-14 15:22:50 +00:00
|
|
|
},
|
|
|
|
|
2023-03-25 00:55:40 +00:00
|
|
|
handleDelete(cache: any, data: { ids: string[], id: string; mlDeleted?: boolean; }, isBulk: boolean) {
|
2022-11-14 15:22:50 +00:00
|
|
|
try {
|
|
|
|
if (cache == null || (!isBulk && !cache.has(data.id))) return cache;
|
|
|
|
|
2023-09-05 17:39:22 +00:00
|
|
|
const mutate = (id: string) => {
|
2022-11-14 15:22:50 +00:00
|
|
|
const msg = cache.get(id);
|
|
|
|
if (!msg) return;
|
|
|
|
|
|
|
|
const EPHEMERAL = 64;
|
2023-03-25 00:55:40 +00:00
|
|
|
const shouldIgnore = data.mlDeleted ||
|
|
|
|
(msg.flags & EPHEMERAL) === EPHEMERAL ||
|
2023-09-05 17:39:22 +00:00
|
|
|
this.shouldIgnore(msg);
|
2022-11-14 15:22:50 +00:00
|
|
|
|
|
|
|
if (shouldIgnore) {
|
|
|
|
cache = cache.remove(id);
|
|
|
|
} else {
|
|
|
|
cache = cache.update(id, m => m
|
|
|
|
.set("deleted", true)
|
|
|
|
.set("attachments", m.attachments.map(a => (a.deleted = true, a))));
|
|
|
|
}
|
2023-09-05 17:39:22 +00:00
|
|
|
};
|
2022-11-14 15:22:50 +00:00
|
|
|
|
|
|
|
if (isBulk) {
|
|
|
|
data.ids.forEach(mutate);
|
|
|
|
} else {
|
|
|
|
mutate(data.id);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
new Logger("MessageLogger").error("Error during handleDelete", e);
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
2022-11-14 15:22:50 +00:00
|
|
|
return cache;
|
2022-11-13 22:13:32 +00:00
|
|
|
},
|
|
|
|
|
2024-03-16 02:27:59 +00:00
|
|
|
shouldIgnore(message: any, isEdit = false) {
|
|
|
|
const { ignoreBots, ignoreSelf, ignoreUsers, ignoreChannels, ignoreGuilds, logEdits, logDeletes } = Settings.plugins.MessageLogger;
|
2023-09-05 17:39:22 +00:00
|
|
|
const myId = UserStore.getCurrentUser().id;
|
|
|
|
|
|
|
|
return ignoreBots && message.author?.bot ||
|
|
|
|
ignoreSelf && message.author?.id === myId ||
|
|
|
|
ignoreUsers.includes(message.author?.id) ||
|
|
|
|
ignoreChannels.includes(message.channel_id) ||
|
2023-09-06 16:50:20 +00:00
|
|
|
ignoreChannels.includes(ChannelStore.getChannel(message.channel_id)?.parent_id) ||
|
2024-03-16 02:27:59 +00:00
|
|
|
(isEdit ? !logEdits : !logDeletes) ||
|
2024-04-30 20:34:45 +00:00
|
|
|
ignoreGuilds.includes(ChannelStore.getChannel(message.channel_id)?.guild_id) ||
|
|
|
|
// Ignore Venbot in the support channel
|
|
|
|
(message.channel_id === "1026515880080842772" && message.author?.id === "1017176847865352332");
|
2023-09-05 17:39:22 +00:00
|
|
|
},
|
|
|
|
|
2022-11-13 22:13:32 +00:00
|
|
|
patches: [
|
|
|
|
{
|
|
|
|
// MessageStore
|
2024-03-28 02:47:00 +00:00
|
|
|
find: '"MessageStore"',
|
2022-11-13 22:13:32 +00:00
|
|
|
replacement: [
|
|
|
|
{
|
|
|
|
// Add deleted=true to all target messages in the MESSAGE_DELETE event
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /MESSAGE_DELETE:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace:
|
|
|
|
"MESSAGE_DELETE:function($1){" +
|
|
|
|
" var cache = $2getOrCreate($1.channelId);" +
|
2023-02-10 21:41:49 +00:00
|
|
|
" cache = $self.handleDelete(cache, $1, false);" +
|
2022-11-13 22:13:32 +00:00
|
|
|
" $2commit(cache);" +
|
|
|
|
"},"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Add deleted=true to all target messages in the MESSAGE_DELETE_BULK event
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /MESSAGE_DELETE_BULK:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace:
|
|
|
|
"MESSAGE_DELETE_BULK:function($1){" +
|
|
|
|
" var cache = $2getOrCreate($1.channelId);" +
|
2023-02-10 21:41:49 +00:00
|
|
|
" cache = $self.handleDelete(cache, $1, true);" +
|
2022-11-13 22:13:32 +00:00
|
|
|
" $2commit(cache);" +
|
|
|
|
"},"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Add current cached content + new edit time to cached message's editHistory
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /(MESSAGE_UPDATE:function\((\i)\).+?)\.update\((\i)/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace: "$1" +
|
|
|
|
".update($3,m =>" +
|
2024-03-16 02:27:59 +00:00
|
|
|
" (($2.message.flags & 64) === 64 || $self.shouldIgnore($2.message, true)) ? m :" +
|
2024-06-12 00:32:33 +00:00
|
|
|
" $2.message.edited_timestamp && $2.message.content !== m.content ?" +
|
2023-02-10 21:41:49 +00:00
|
|
|
" m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" +
|
2022-11-13 22:13:32 +00:00
|
|
|
" m" +
|
|
|
|
")" +
|
|
|
|
".update($3"
|
2023-04-02 20:14:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// fix up key (edit last message) attempting to edit a deleted message
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /(?<=getLastEditableMessage\(\i\)\{.{0,200}\.find\((\i)=>)/,
|
|
|
|
replace: "!$1.deleted &&"
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Message domain model
|
2023-10-25 21:46:51 +00:00
|
|
|
find: "}addReaction(",
|
2022-11-13 22:13:32 +00:00
|
|
|
replacement: [
|
|
|
|
{
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /this\.customRenderedContent=(\i)\.customRenderedContent,/,
|
|
|
|
replace: "this.customRenderedContent = $1.customRenderedContent," +
|
|
|
|
"this.deleted = $1.deleted || false," +
|
|
|
|
"this.editHistory = $1.editHistory || [],"
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Updated message transformer(?)
|
|
|
|
find: "THREAD_STARTER_MESSAGE?null===",
|
|
|
|
replacement: [
|
|
|
|
{
|
|
|
|
// Pass through editHistory & deleted & original attachments to the "edited message" transformer
|
2024-05-23 01:25:02 +00:00
|
|
|
match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace:
|
2024-05-23 01:25:02 +00:00
|
|
|
"Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })"
|
2022-11-13 22:13:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Construct new edited message and add editHistory & deleted (ref above)
|
|
|
|
// Pass in custom data to attachment parser to mark attachments deleted as well
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /attachments:(\i)\((\i)\)/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace:
|
|
|
|
"attachments: $1((() => {" +
|
2023-11-15 18:13:19 +00:00
|
|
|
" if ($self.shouldIgnore($2)) return $2;" +
|
2022-11-13 22:13:32 +00:00
|
|
|
" let old = arguments[1]?.attachments;" +
|
|
|
|
" if (!old) return $2;" +
|
|
|
|
" let new_ = $2.attachments?.map(a => a.id) ?? [];" +
|
|
|
|
" let diff = old.filter(a => !new_.includes(a.id));" +
|
|
|
|
" old.forEach(a => a.deleted = true);" +
|
|
|
|
" $2.attachments = [...diff, ...$2.attachments];" +
|
|
|
|
" return $2;" +
|
|
|
|
"})())," +
|
|
|
|
"deleted: arguments[1]?.deleted," +
|
|
|
|
"editHistory: arguments[1]?.editHistory"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Preserve deleted attribute on attachments
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /(\((\i)\){return null==\2\.attachments.+?)spoiler:/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace:
|
|
|
|
"$1deleted: arguments[0]?.deleted," +
|
|
|
|
"spoiler:"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Attachment renderer
|
2024-04-16 20:11:25 +00:00
|
|
|
find: ".removeMosaicItemHoverButton",
|
2023-12-21 22:41:12 +00:00
|
|
|
group: true,
|
2022-11-13 22:13:32 +00:00
|
|
|
replacement: [
|
|
|
|
{
|
2024-04-16 20:11:25 +00:00
|
|
|
match: /(className:\i,item:\i),/,
|
|
|
|
replace: "$1,item: deleted,"
|
2022-11-13 22:13:32 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /\[\i\.obscured\]:.+?,/,
|
|
|
|
replace: "$& 'messagelogger-deleted-attachment': deleted,"
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Base message component renderer
|
|
|
|
find: "Message must not be a thread starter message",
|
|
|
|
replacement: [
|
|
|
|
{
|
2023-01-30 04:02:17 +00:00
|
|
|
// Append messagelogger-deleted to classNames if deleted
|
2022-11-13 22:13:32 +00:00
|
|
|
match: /\)\("li",\{(.+?),className:/,
|
2023-03-25 00:55:40 +00:00
|
|
|
replace: ")(\"li\",{$1,className:(arguments[0].message.deleted ? \"messagelogger-deleted \" : \"\")+"
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Message content renderer
|
|
|
|
find: "Messages.MESSAGE_EDITED,\")\"",
|
|
|
|
replacement: [
|
|
|
|
{
|
|
|
|
// Render editHistory in the deepest div for message content
|
|
|
|
match: /(\)\("div",\{id:.+?children:\[)/,
|
2024-06-07 21:28:17 +00:00
|
|
|
replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),"
|
2022-11-13 22:13:32 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// ReferencedMessageStore
|
2024-03-28 02:47:00 +00:00
|
|
|
find: '"ReferencedMessageStore"',
|
2022-11-13 22:13:32 +00:00
|
|
|
replacement: [
|
|
|
|
{
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /MESSAGE_DELETE:function\((\i)\).+?},/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace: "MESSAGE_DELETE:function($1){},"
|
|
|
|
},
|
|
|
|
{
|
2023-10-25 21:46:51 +00:00
|
|
|
match: /MESSAGE_DELETE_BULK:function\((\i)\).+?},/,
|
2022-11-13 22:13:32 +00:00
|
|
|
replace: "MESSAGE_DELETE_BULK:function($1){},"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Message context base menu
|
2023-10-25 21:46:51 +00:00
|
|
|
find: "useMessageMenu:",
|
2022-11-13 22:13:32 +00:00
|
|
|
replacement: [
|
|
|
|
{
|
|
|
|
// Remove the first section if message is deleted
|
|
|
|
match: /children:(\[""===.+?\])/,
|
|
|
|
replace: "children:arguments[0].message.deleted?[]:$1"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|