diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 03c30ede..d251ff74 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -74,9 +74,9 @@ export default definePlugin({ } }, { - find: 'react-spring: The "interpolate" function', + find: 'The "interpolate" function is deprecated in v10 (use "to" instead)', replacement: { - match: /,console.warn\('react-spring: The "interpolate" function is deprecated in v10 \(use "to" instead\)'\)/, + match: /,console.warn\(\i\+'The "interpolate" function is deprecated in v10 \(use "to" instead\)'\)/, replace: "" } }, @@ -133,7 +133,7 @@ export default definePlugin({ { find: "Slow dispatch on", replacement: { - match: /\i\.totalTime>100&&\i\.verbose\("Slow dispatch on ".+?\)\);/, + match: /\i\.totalTime>\i&&\i\.verbose\("Slow dispatch on ".+?\)\);/, replace: "" } }, diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 86c5ae4d..d1aa69c7 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -207,8 +207,8 @@ function makeBypassPatches(): Omit { return { find: "canUseCustomStickersEverywhere:", replacement: mapping.map(({ func, predicate }) => ({ - match: new RegExp(String.raw`(?<=${func}:function\(\i(?:,\i)?\){)`), - replace: "return true;", + match: new RegExp(String.raw`(?<=${func}:)\i`), + replace: "() => true", predicate })) }; @@ -297,8 +297,8 @@ export default definePlugin({ replacement: [ { // Overwrite incoming connection settings proto with our local settings - match: /CONNECTION_OPEN:function\((\i)\){/, - replace: (m, props) => `${m}$self.handleProtoChange(${props}.userSettingsProto,${props}.user);` + match: /function (\i)\((\i)\){(?=.*CONNECTION_OPEN:\1)/, + replace: (m, funcName, props) => `${m}$self.handleProtoChange(${props}.userSettingsProto,${props}.user);` }, { // Overwrite non local proto changes with our local settings diff --git a/src/plugins/favEmojiFirst/index.ts b/src/plugins/favEmojiFirst/index.ts index d1a5458d..aa43a528 100644 --- a/src/plugins/favEmojiFirst/index.ts +++ b/src/plugins/favEmojiFirst/index.ts @@ -57,7 +57,7 @@ export default definePlugin({ { // https://regex101.com/r/x2mobQ/1 // searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length) - match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(\i-\i\.length)\)/, + match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(Math\.max\(\i,\i(?:-\i\.length){2})\)/, // ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis) replace: ",maxCount:Infinity$2=($3.sliceTo = $4, $3)" } diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index a79e3f31..3d32d625 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -346,35 +346,35 @@ export default definePlugin({ replacement: [ { // Add deleted=true to all target messages in the MESSAGE_DELETE event - match: /MESSAGE_DELETE:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/, + match: /function (?=.+?MESSAGE_DELETE:(\i))\1\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?}(?=function)/, replace: - "MESSAGE_DELETE:function($1){" + - " var cache = $2getOrCreate($1.channelId);" + - " cache = $self.handleDelete(cache, $1, false);" + - " $2commit(cache);" + - "}," + "function $1($2){" + + " var cache = $3getOrCreate($2.channelId);" + + " cache = $self.handleDelete(cache, $2, false);" + + " $3commit(cache);" + + "}" }, { // Add deleted=true to all target messages in the MESSAGE_DELETE_BULK event - match: /MESSAGE_DELETE_BULK:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/, + match: /function (?=.+?MESSAGE_DELETE_BULK:(\i))\1\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?}(?=function)/, replace: - "MESSAGE_DELETE_BULK:function($1){" + - " var cache = $2getOrCreate($1.channelId);" + - " cache = $self.handleDelete(cache, $1, true);" + - " $2commit(cache);" + - "}," + "function $1($2){" + + " var cache = $3getOrCreate($2.channelId);" + + " cache = $self.handleDelete(cache, $2, true);" + + " $3commit(cache);" + + "}" }, { // Add current cached content + new edit time to cached message's editHistory - match: /(MESSAGE_UPDATE:function\((\i)\).+?)\.update\((\i)/, + match: /(function (\i)\((\i)\).+?)\.update\((\i)(?=.*MESSAGE_UPDATE:\2)/, replace: "$1" + - ".update($3,m =>" + - " (($2.message.flags & 64) === 64 || $self.shouldIgnore($2.message, true)) ? m :" + - " $2.message.edited_timestamp && $2.message.content !== m.content ?" + - " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" + + ".update($4,m =>" + + " (($3.message.flags & 64) === 64 || $self.shouldIgnore($3.message, true)) ? m :" + + " $3.message.edited_timestamp && $3.message.content !== m.content ?" + + " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($3.message, m)]) :" + " m" + ")" + - ".update($3" + ".update($4" }, { // fix up key (edit last message) attempting to edit a deleted message @@ -488,12 +488,12 @@ export default definePlugin({ find: '"ReferencedMessageStore"', replacement: [ { - match: /MESSAGE_DELETE:function\((\i)\).+?},/, - replace: "MESSAGE_DELETE:function($1){}," + match: /MESSAGE_DELETE:\i,/, + replace: "MESSAGE_DELETE:()=>{}," }, { - match: /MESSAGE_DELETE_BULK:function\((\i)\).+?},/, - replace: "MESSAGE_DELETE_BULK:function($1){}," + match: /MESSAGE_DELETE_BULK:\i,/, + replace: "MESSAGE_DELETE_BULK:()=>{}," } ] }, diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 6c9102d8..6a438675 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -183,8 +183,8 @@ export default definePlugin({ { find: ".ORIGINAL_POSTER=", replacement: { - match: /\((\i)=\{\}\)\)\[(\i)\.BOT/, - replace: "($1=$self.getTagTypes()))[$2.BOT" + match: /(?=(\i)\[\i\.BOT)/, + replace: "$self.genTagTypes($1);" } }, { @@ -280,8 +280,7 @@ export default definePlugin({ .filter(Boolean); }, - getTagTypes() { - const obj = {}; + genTagTypes(obj) { let i = 100; tags.forEach(({ name }) => { obj[name] = ++i; @@ -291,7 +290,6 @@ export default definePlugin({ obj[`${name}-OP`] = ++i; obj[i] = `${name}-OP`; }); - return obj; }, isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 65ce6136..48ca63d1 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -54,8 +54,8 @@ export default definePlugin({ predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true, replacement: [ { - match: /(?<=MESSAGE_CREATE:function\((\i)\){)/, - replace: (_, props) => `if($self.isBlocked(${props}.message))return;` + match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/, + replace: (_, _funcName, props) => `if($self.isBlocked(${props}.message))return;` } ] })) diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 4b98e666..914deaa0 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -74,10 +74,10 @@ export default definePlugin({ // This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests) // In short, only the red badge is hidden. Button visibility behavior isn't changed. { - find: ".getSpamChannelsCount()", + find: ".getSpamChannelsCount();return", predicate: () => settings.store.hideMessageRequestsCount, replacement: { - match: /(?<=getSpamChannelsCount\(\),\i=)\i\.getMessageRequestsCount\(\)/, + match: /(?<=getSpamChannelsCount\(\);return )\i\.getMessageRequestsCount\(\)/, replace: "$self.getRealMessageRequestCount()" } }, diff --git a/src/plugins/volumeBooster/index.ts b/src/plugins/volumeBooster/index.ts index 241111d4..c9a08bbc 100644 --- a/src/plugins/volumeBooster/index.ts +++ b/src/plugins/volumeBooster/index.ts @@ -94,7 +94,7 @@ export default definePlugin({ find: "AudioContextSettingsMigrated", replacement: [ { - match: /(?<=isLocalMute\(\i,\i\),volume:.+?volume:)\i(?=})/, + match: /(?<=isLocalMute\(\i,\i\),volume:(\i).+?\i\(\i,\i,)\1(?=\))/, replace: "$&>200?200:$&" }, { @@ -109,7 +109,7 @@ export default definePlugin({ }, // Prevent the MediaEngineStore from overwriting our LocalVolumes above 200 with the ones the Discord Audio Context Settings sync sends { - find: '"MediaEngineStore"', + find: '="MediaEngineStore",', replacement: [ { match: /(\.settings\.audioContextSettings.+?)(\i\[\i\])=(\i\.volume)(.+?setLocalVolume\(\i,).+?\)/, diff --git a/src/plugins/whoReacted/index.tsx b/src/plugins/whoReacted/index.tsx index 24be9bef..bcd07079 100644 --- a/src/plugins/whoReacted/index.tsx +++ b/src/plugins/whoReacted/index.tsx @@ -113,8 +113,8 @@ export default definePlugin({ { find: '"MessageReactionsStore"', replacement: { - match: /(?<=CONNECTION_OPEN:function\(\){)(\i)={}/, - replace: "$&;$self.reactions=$1" + match: /function (\i)\(\){(\i)={}(?=.*CONNECTION_OPEN:\1)/, + replace: "$&;$self.reactions=$2;" } }, {