diff --git a/bin/one-time/flavor-text-color-fix b/bin/one-time/flavor-text-color-fix
new file mode 100755
index 0000000..898691a
--- /dev/null
+++ b/bin/one-time/flavor-text-color-fix
@@ -0,0 +1,53 @@
+#!/usr/bin/env -S node --env-file-if-exists=.env
+// Fixes flavor text formatting on files robogurgum created for patches 7.3/7.31
+// see https://discord.com/channels/312060255469305856/1412850908668100810
+
+import {getMediawikiClient} from '../../lib/config.js';
+import {diff} from '../../lib/util/diff.js';
+
+const mw = await getMediawikiClient();
+
+function fixPageContent (pageContent) {
+ const flavorTextRegexp = /\| flavor-text = ([\s\S]*?)\n\|/;
+
+ let match = pageContent.match(flavorTextRegexp);
+ if (!match) return pageContent;
+ let flavorText = match[1];
+ if (!flavorText.trim()) return pageContent;
+
+ let newFlavorText = flavorText
+ // linebreaks with
+ // - no
or
etc before or after
+ // - no {{action fact}} after (that renders a line break at the start)
+ .replace(/(?)\n(?!
)(?!{{action fact|\s*$)/gi, '
\n')
+ // spans that set color via inline style instead of using {{colorize}}
+ .replace(/([^<]+)<\/span>/g, '`$1`')
+ .replace(/([^<]+)<\/span>/g, '``$1``')
+ .replace(/([^<]+)<\/span>/g, '```$1```')
+ // convert lunar/phaenna credit bonuses to use {{action fact}}, but only
+ // when we can be sure it won't add extra line breaks
+ .replace(
+ /
(\n?)`([\w\d _-]+)(?<=Credit Bonus)(?::`|`:) +([^\n<]+)/g,
+ '$1{{action fact|$2|$3}}',
+ )
+ // flavor-text is automatically colorized, remove redundant invocations
+ .replace(/{{colorize\|([^|{}]+)}}/g, '$1');
+
+ return pageContent.replace(flavorTextRegexp, `| flavor-text = ${newFlavorText}\n|`);
+}
+
+const pages = await mw.listUserContribs('RoboGurgum', {namespaces: [0], show: 'new', limit: 1000});
+for (const page of pages) {
+ const {title} = page;
+ const pageContent = await mw.readPage(title);
+ let fixedContent = fixPageContent(pageContent);
+ if (fixedContent === pageContent) {
+ console.log('#', title, ' No change\n');
+ continue;
+ }
+ console.write('\n');
+ diff(pageContent, fixedContent, page);
+ console.log();
+
+ await mw.editPage(title, fixedContent, 'fix flavor text formatting', true);
+}