diff --git a/module/tweaks/chatImageLinks.mjs b/module/tweaks/chatImageLinks.mjs index b75ad9c..6b4b226 100644 --- a/module/tweaks/chatImageLinks.mjs +++ b/module/tweaks/chatImageLinks.mjs @@ -28,7 +28,7 @@ export function chatImageLinks() { type: Boolean, default: true, config: true, - requiresReload: true, + requiresReload: false, onChange: (newValue) => { if (newValue) { hookID = Hooks.on(`chatMessage`, chatMessageHandler); @@ -37,13 +37,6 @@ export function chatImageLinks() { }; }, }); - - game.settings.register(__ID__, key + `-showPromptAgain`, { - scope: `user`, - type: Boolean, - default: true, - config: false, - }); // #endregion Registration // #region Implementation @@ -65,9 +58,6 @@ const pattern = new RegExp( // MARK: Mutate & Resend const handled = new Set(); async function mutateAndResendMessage(chatLog, message, options) { - const match = message.match(pattern); - if (!match) { return }; - const validMatches = new Set(); const matches = message.match(pattern); @@ -99,7 +89,14 @@ async function mutateAndResendMessage(chatLog, message, options) { */ function chatMessageHandler(chatLog, message, options) { if (!game.settings.get(__ID__, key)) { return }; + + // Don't re-process the same message if (handled.has(message)) { return }; + + // Prevent cancellation for non-matching messages + const match = message.match(pattern); + if (!match) { return }; + mutateAndResendMessage(chatLog, message, options); return false; };