Add some support for feature flags in addition to making roll modes work with custom chat formats

This commit is contained in:
Oliver-Akins 2024-09-03 00:40:41 -06:00
parent f238db1c4d
commit 444af027b3
7 changed files with 88 additions and 7 deletions

View file

@ -0,0 +1,21 @@
import { FEATURE_FLAGS } from "../consts.mjs";
Hooks.on(`renderChatMessage`, (msg, html) => {
// Short-Circuit when the flag isn't set for the message
if (msg.getFlag(`taf`, `rollModedContent`)) {
return;
}
const featureFlags = game.settings.get(game.system.id, `flags`);
const featureFlagEnabled = featureFlags.includes(FEATURE_FLAGS.ROLLMODECONTENT);
const contentElement = html.find(`.message-content`)[0];
let content = contentElement.innerHTML;
if (featureFlagEnabled && msg.blind && !game.user.isGM) {
content = content.replace(/-=.*?=-/gm, `???`);
} else {
content = content.replace(/-=|=-/gm, ``);
}
contentElement.innerHTML = content;
});