Fix MessageLogger (#1888)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
Ben Richeson 2023-10-25 17:46:51 -04:00 committed by GitHub
parent 38daf6ec2b
commit 53cd14844f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 24 deletions

@ -1,10 +1,10 @@
/* Message content highlighting */
.messagelogger-deleted [class*="contents-"] > :is(div, h1, h2, h3, p) {
.messagelogger-deleted [class*="contents"] > :is(div, h1, h2, h3, p) {
color: #f04747 !important;
}
/* Bot "thinking" text highlighting */
.messagelogger-deleted [class*="colorStandard-"] {
.messagelogger-deleted [class*="colorStandard"] {
color: #f04747 !important;
}

@ -210,7 +210,7 @@ export default definePlugin({
ignoreGuilds.includes(ChannelStore.getChannel(message.channel_id)?.guild_id);
},
// Based on canary 9ab8626bcebceaea6da570b9c586172d02b9c996
// Based on canary 63b8f1b4f2025213c5cf62f0966625bee3d53136
patches: [
{
// MessageStore
@ -219,7 +219,7 @@ export default definePlugin({
replacement: [
{
// Add deleted=true to all target messages in the MESSAGE_DELETE event
match: /MESSAGE_DELETE:function\((\w)\){var .+?((?:\w{1,2}\.){2})getOrCreate.+?},/,
match: /MESSAGE_DELETE:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/,
replace:
"MESSAGE_DELETE:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
@ -229,7 +229,7 @@ export default definePlugin({
},
{
// Add deleted=true to all target messages in the MESSAGE_DELETE_BULK event
match: /MESSAGE_DELETE_BULK:function\((\w)\){var .+?((?:\w{1,2}\.){2})getOrCreate.+?},/,
match: /MESSAGE_DELETE_BULK:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/,
replace:
"MESSAGE_DELETE_BULK:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
@ -239,7 +239,7 @@ export default definePlugin({
},
{
// Add current cached content + new edit time to cached message's editHistory
match: /(MESSAGE_UPDATE:function\((\w)\).+?)\.update\((\w)/,
match: /(MESSAGE_UPDATE:function\((\i)\).+?)\.update\((\i)/,
replace: "$1" +
".update($3,m =>" +
" (($2.message.flags & 64) === 64 || $self.shouldIgnore($2.message)) ? m :" +
@ -251,8 +251,8 @@ export default definePlugin({
},
{
// fix up key (edit last message) attempting to edit a deleted message
match: /(?<=getLastEditableMessage=.{0,200}\.find\(\(function\((\i)\)\{)return/,
replace: "return !$1.deleted &&"
match: /(?<=getLastEditableMessage\(\i\)\{.{0,200}\.find\((\i)=>)/,
replace: "!$1.deleted &&"
}
]
},
@ -260,13 +260,13 @@ export default definePlugin({
{
// Message domain model
// Module 451
find: "isFirstMessageInForumPost=function",
find: "}addReaction(",
replacement: [
{
match: /(\w)\.customRenderedContent=(\w)\.customRenderedContent;/,
replace: "$1.customRenderedContent = $2.customRenderedContent;" +
"$1.deleted = $2.deleted || false;" +
"$1.editHistory = $2.editHistory || [];"
match: /this\.customRenderedContent=(\i)\.customRenderedContent,/,
replace: "this.customRenderedContent = $1.customRenderedContent," +
"this.deleted = $1.deleted || false," +
"this.editHistory = $1.editHistory || [],"
}
]
},
@ -283,7 +283,7 @@ export default definePlugin({
// },
{
// Pass through editHistory & deleted & original attachments to the "edited message" transformer
match: /interactionData:(\w)\.interactionData/,
match: /interactionData:(\i)\.interactionData/,
replace:
"interactionData:$1.interactionData," +
"deleted:$1.deleted," +
@ -299,7 +299,7 @@ export default definePlugin({
{
// Construct new edited message and add editHistory & deleted (ref above)
// Pass in custom data to attachment parser to mark attachments deleted as well
match: /attachments:(\w{1,2})\((\w)\)/,
match: /attachments:(\i)\((\i)\)/,
replace:
"attachments: $1((() => {" +
" let old = arguments[1]?.attachments;" +
@ -315,7 +315,7 @@ export default definePlugin({
},
{
// Preserve deleted attribute on attachments
match: /(\((\w)\){return null==\2\.attachments.+?)spoiler:/,
match: /(\((\i)\){return null==\2\.attachments.+?)spoiler:/,
replace:
"$1deleted: arguments[0]?.deleted," +
"spoiler:"
@ -326,15 +326,15 @@ export default definePlugin({
{
// Attachment renderer
// Module 96063
find: "().removeAttachmentHoverButton",
find: ".removeAttachmentHoverButton",
replacement: [
{
match: /((\w)\.className,\w=\2\.attachment),/,
replace: "$1,deleted=$2.attachment?.deleted,"
match: /(className:\i,attachment:\i),/,
replace: "$1,attachment: {deleted},"
},
{
match: /\["className","attachment".+?className:/,
replace: "$& (deleted ? 'messagelogger-deleted-attachment ' : '') +"
match: /\[\i\.obscured\]:.+?,/,
replace: "$& 'messagelogger-deleted-attachment': deleted,"
}
]
},
@ -371,11 +371,11 @@ export default definePlugin({
find: "displayName=\"ReferencedMessageStore\"",
replacement: [
{
match: /MESSAGE_DELETE:function\((\w)\).+?},/,
match: /MESSAGE_DELETE:function\((\i)\).+?},/,
replace: "MESSAGE_DELETE:function($1){},"
},
{
match: /MESSAGE_DELETE_BULK:function\((\w)\).+?},/,
match: /MESSAGE_DELETE_BULK:function\((\i)\).+?},/,
replace: "MESSAGE_DELETE_BULK:function($1){},"
}
]
@ -384,7 +384,7 @@ export default definePlugin({
{
// Message context base menu
// Module 600300
find: "id:\"remove-reactions\"",
find: "useMessageMenu:",
replacement: [
{
// Remove the first section if message is deleted