diff --git a/packages/userscript/src/constants.ts b/packages/userscript/src/constants.ts index ce692cb..fea7d65 100644 --- a/packages/userscript/src/constants.ts +++ b/packages/userscript/src/constants.ts @@ -2,5 +2,7 @@ export const baseUrl = 'https://chat.openai.com' export const LEGACY_KEY_FILENAME_FORMAT = 'exporter-format' export const KEY_FILENAME_FORMAT = 'exporter:filename_format' +export const KEY_TIMESTAMP_ENABLED = 'exporter:enable_timestamp' +export const KEY_TIMESTAMP_24H = 'exporter:timestamp_24h' export const KEY_META_ENABLED = 'exporter:enable_meta' export const KEY_META_LIST = 'exporter:meta_list' diff --git a/packages/userscript/src/exporter/html.ts b/packages/userscript/src/exporter/html.ts index 4bb15b2..d6f0e7c 100644 --- a/packages/userscript/src/exporter/html.ts +++ b/packages/userscript/src/exporter/html.ts @@ -1,14 +1,15 @@ import JSZip from 'jszip' import { fetchConversation, getCurrentChatId, processConversation } from '../api' -import { baseUrl } from '../constants' +import { KEY_TIMESTAMP_24H, KEY_TIMESTAMP_ENABLED, baseUrl } from '../constants' import { checkIfConversationStarted, getConversationChoice, getUserAvatar } from '../page' import templateHtml from '../template.html?raw' import { downloadFile, getFileNameWithFormat } from '../utils/download' import { fromMarkdown, toHtml } from '../utils/markdown' +import { ScriptStorage } from '../utils/storage' import { standardizeLineBreaks } from '../utils/text' import { dateStr, getColorScheme, timestamp } from '../utils/utils' import type { ApiConversationWithId, ConversationResult } from '../api' -import type { ExportMeta } from '../ui/MetaContext' +import type { ExportMeta } from '../ui/SettingContext' export async function exportToHtml(fileNameFormat: string, metaList: ExportMeta[]) { if (!checkIfConversationStarted()) { @@ -71,17 +72,22 @@ function conversationToHtml(conversation: ConversationResult, avatar: string, me conversationContent = `
${escapeHtml(content)}
` } + const enableTimestamp = ScriptStorage.get