diff --git a/static_content/js/player-name-colors.js b/static_content/js/player-name-colors.js index 8b326a1..5f1eda0 100644 --- a/static_content/js/player-name-colors.js +++ b/static_content/js/player-name-colors.js @@ -38,7 +38,8 @@ function parsePlayerNameColors(name) { const textBefore = name.substring(lastIndex, match.index); if (textBefore) { if (currentColor) { - result += `${escapeHtml(textBefore)}`; + const style = getColorStyle(currentColor); + result += `${escapeHtml(textBefore)}`; } else { result += escapeHtml(textBefore); } @@ -55,7 +56,8 @@ function parsePlayerNameColors(name) { const remainingText = name.substring(lastIndex); if (remainingText) { if (currentColor) { - result += `${escapeHtml(remainingText)}`; + const style = getColorStyle(currentColor); + result += `${escapeHtml(remainingText)}`; } else { result += escapeHtml(remainingText); } @@ -65,6 +67,19 @@ function parsePlayerNameColors(name) { } /** + * Get the style string for a color, adding black background for white text + * @param {string} color - The color hex code + * @returns {string} CSS style string + */ +function getColorStyle(color) { + // Add black background for white text to make it visible + if (color === '#FFFFFF') { + return `color: ${color}; background-color: #000000; padding: 0 2px;`; + } + return `color: ${color}`; +} + +/** * Escape HTML special characters * @param {string} text - Text to escape * @returns {string} Escaped text