Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 133 additions & 132 deletions content-script.js
Original file line number Diff line number Diff line change
@@ -1,142 +1,143 @@
// content.js
// Injected on toolbar click. Exports current chat page to standalone HTML.

const TEMPLATE_HTML = `
<!DOCTYPE html>
<html lang="en-EN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{title}}</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; line-height: 1.6; max-width: 1200px; margin: 0 auto; padding: 20px; background-color: #f5f5f5; }
.chat-container { background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.1); overflow: hidden; }
.chat-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; padding: 20px; text-align: center; }
.chat-header h1 { margin: 0; font-size: 1.5em; }
.chat-header .export-info { margin-top: 10px; font-size: .9em; opacity: .9; }
.message { padding: 20px; border-bottom: 1px solid #eee; }
.message:last-child { border-bottom: none; }
.message-header { font-weight: bold; margin-bottom: 10px; padding: 8px 12px; border-radius: 6px; display: inline-block; }
.message-header.user { background: #e3f2fd; color: #1976d2; }
.message-header.assistant { background: #f3e5f5; color: #7b1fa2; }
.message-header.system { background: #fff3e0; color: #f57c00; }
.message-header.unknown { background: #f5f5f5; color: #666; }
.message-content { margin-top: 10px; }
(function() {

const TEMPLATE_HTML = `
<!DOCTYPE html>
<html lang="en-EN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{title}}</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; line-height: 1.6; max-width: 1200px; margin: 0 auto; padding: 20px; background-color: #f5f5f5; }
.chat-container { background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.1); overflow: hidden; }
.chat-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; padding: 20px; text-align: center; }
.chat-header h1 { margin: 0; font-size: 1.5em; }
.chat-header .export-info { margin-top: 10px; font-size: .9em; opacity: .9; }
.message { padding: 20px; border-bottom: 1px solid #eee; }
.message:last-child { border-bottom: none; }
.message-header { font-weight: bold; margin-bottom: 10px; padding: 8px 12px; border-radius: 6px; display: inline-block; }
.message-header.user { background: #e3f2fd; color: #1976d2; }
.message-header.assistant { background: #f3e5f5; color: #7b1fa2; }
.message-header.system { background: #fff3e0; color: #f57c00; }
.message-header.unknown { background: #f5f5f5; color: #666; }
.message-content { margin-top: 10px; }

/* Header 1 Style */
h1 {
font-size: 1.5em;
margin: 1.2em 0 0.7em 0;
font-weight: 700;
line-height: 1.2;
}
h2 {
font-size: 1.2em;
margin: 1.1em 0 0.6em 0;
font-weight: 600;
line-height: 1.25;
}
/* Dialog message N title style */
.message-header {
font-size: 1.2em;
font-weight: 600;
margin-bottom: 10px;
padding: 8px 12px;
border-radius: 6px;
display: inline-block;
background: #f5f5f5;
color: #666;
}
/* Header 1 Style */
h1 {
font-size: 1.5em;
margin: 1.2em 0 0.7em 0;
font-weight: 700;
line-height: 1.2;
}
h2 {
font-size: 1.2em;
margin: 1.1em 0 0.6em 0;
font-weight: 600;
line-height: 1.25;
}
/* Dialog message N title style */
.message-header {
font-size: 1.2em;
font-weight: 600;
margin-bottom: 10px;
padding: 8px 12px;
border-radius: 6px;
display: inline-block;
background: #f5f5f5;
color: #666;
}

/* Code block beautification(Darkboxstyle+title frame) */
.code-block-box {
margin: 1.5em 0;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
background: #181c24;
border: 1px solid #23272f;
overflow: hidden;
}
.code-title-frame {
display: flex;
align-items: center;
justify-content: space-between;
background: #f5f6fa;
color: #23272f;
font-size: 13px;
font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', 'Menlo', 'Monaco', 'monospace';
padding: 0.35em 1.1em 0.35em 1.1em;
border-bottom: 1px solid #e0e0e0;
border-radius: 10px 10px 0 0;
}
.code-lang-label {
font-weight: 600;
background: #23272f;
color: #e6eaf3;
opacity: 1;
letter-spacing: 0.5px;
border-radius: 5px;
padding: 0.15em 0.7em;
font-size: 90%;
margin-right: 0.5em;
display: inline-block;
}
.copy-button {
background: #e6eaf3;
color: #23272f;
border: none;
border-radius: 6px;
padding: 2px 12px;
font-size: 12px;
cursor: pointer;
opacity: 0.85;
transition: background 0.2s, opacity 0.2s;
z-index: 2;
}
.copy-button:hover {
background: #d3d7e3;
opacity: 1;
}
.code-block-box pre {
background: #181c24;
color: #e6eaf3;
border: none;
border-radius: 0 0 10px 10px;
margin: 0;
padding: 1em 1.2em;
font-size: 14px;
overflow-x: auto;
box-shadow: none;
}
.code-block-box code {
background: none;
color: inherit;
padding: 0;
border: none;
font-size: inherit;
}
code:not(pre code) {
background: #23272f;
color: #e6eaf3;
border-radius: 5px;
padding: 0.2em 0.4em;
font-size: 95%;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="chat-header">
<h1>{{title}}</h1>
<div class="export-info">Export time: {{exportTime}} GMT+8 | Platform: {{platform}}</div>
/* Code block beautification(Darkboxstyle+title frame) */
.code-block-box {
margin: 1.5em 0;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
background: #181c24;
border: 1px solid #23272f;
overflow: hidden;
}
.code-title-frame {
display: flex;
align-items: center;
justify-content: space-between;
background: #f5f6fa;
color: #23272f;
font-size: 13px;
font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', 'Menlo', 'Monaco', 'monospace';
padding: 0.35em 1.1em 0.35em 1.1em;
border-bottom: 1px solid #e0e0e0;
border-radius: 10px 10px 0 0;
}
.code-lang-label {
font-weight: 600;
background: #23272f;
color: #e6eaf3;
opacity: 1;
letter-spacing: 0.5px;
border-radius: 5px;
padding: 0.15em 0.7em;
font-size: 90%;
margin-right: 0.5em;
display: inline-block;
}
.copy-button {
background: #e6eaf3;
color: #23272f;
border: none;
border-radius: 6px;
padding: 2px 12px;
font-size: 12px;
cursor: pointer;
opacity: 0.85;
transition: background 0.2s, opacity 0.2s;
z-index: 2;
}
.copy-button:hover {
background: #d3d7e3;
opacity: 1;
}
.code-block-box pre {
background: #181c24;
color: #e6eaf3;
border: none;
border-radius: 0 0 10px 10px;
margin: 0;
padding: 1em 1.2em;
font-size: 14px;
overflow-x: auto;
box-shadow: none;
}
.code-block-box code {
background: none;
color: inherit;
padding: 0;
border: none;
font-size: inherit;
}
code:not(pre code) {
background: #23272f;
color: #e6eaf3;
border-radius: 5px;
padding: 0.2em 0.4em;
font-size: 95%;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="chat-header">
<h1>{{title}}</h1>
<div class="export-info">Export time: {{exportTime}} GMT+8 | Platform: {{platform}}</div>
</div>
{{content}}
</div>
{{content}}
</div>
</body>
</html>
`;
</body>
</html>
`;

(function() {
function formatExportTime() {
const now = new Date();
return now.toLocaleString('en-US', {
Expand Down