WorkBuddy、CodeBuddy 桌面端增强助手:签到猫猫旅行成长计划查询、多账号独立备份、点切即用;免打扰模式让 AI 无人值守跑长任务;跨账号会话迁移、异常中断自动续接;暂存/快捷提示词;毛玻璃主题与更多实用功能。
import { Marked } from 'marked';
import DOMPurify from 'dompurify';
const escape = text => String(text).replace(/[&<>"']/g, ch => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[ch]));
const parser = new Marked({ gfm: true, breaks: false, renderer: {
// Preview images as their labels; hovering must not initiate external requests.
image({ text }) { return escape(text || '图片'); },
html({ text }) { return escape(text); },
} });
window.__wbsMarkdownPreview = {
render(text) {
const html = parser.parse(String(text).slice(0, 20000));
return DOMPurify.sanitize(html, {
ALLOWED_TAGS: ['p', 'br', 'hr', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong', 'em', 'del', 's', 'blockquote', 'ul', 'ol', 'li', 'pre', 'code', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'a', 'input'],
// Links remain readable without navigating the official renderer.
ALLOWED_ATTR: ['start', 'align', 'type', 'checked', 'disabled'],
ALLOW_DATA_ATTR: false,
ALLOW_ARIA_ATTR: false,
RETURN_DOM_FRAGMENT: true,
...(window.__wbsTrustedHtmlPolicy ? { TRUSTED_TYPES_POLICY: window.__wbsTrustedHtmlPolicy } : {}),
});
},
};