ui: redesign Side Panel with dark OLED theme

- Dark OLED background (#0a0a0b) with surface/elevated layers
- Inter font for UI, JetBrains Mono for code/data
- Blue/green/orange/red semantic color system with subtle glow effects
- Step indicators with colored circles showing state (running/completed/failed)
- Animated status dot (pulse) for running state
- Custom scrollbar, log line animations, step state transitions
- Auto Run button with SVG icons and state changes
- Console section with Clear button
- Progress counter (0/9)
- Respects prefers-reduced-motion
This commit is contained in:
unknown
2026-04-05 09:47:58 +08:00
parent 1c1e589bdc
commit 053a2188bc
3 changed files with 563 additions and 277 deletions
+375 -132
View File
@@ -1,26 +1,82 @@
/* sidepanel/sidepanel.css */ /* ============================================================
MultiPage Automation — Side Panel Theme
Design: Dark OLED / Developer Tool
Font: Inter (UI) + JetBrains Mono (code/data)
Colors: Blue primary (#2563EB), Green success (#22C55E),
Orange warning (#F97316), Red error (#EF4444)
============================================================ */
:root {
--bg-base: #0a0a0b;
--bg-surface: #141416;
--bg-elevated: #1c1c20;
--bg-hover: #252529;
--bg-active: #2a2a30;
--border: #2a2a30;
--border-subtle: #1e1e22;
--text-primary: #e8e8ed;
--text-secondary: #8b8b96;
--text-muted: #5c5c66;
--blue: #2563eb;
--blue-glow: rgba(37, 99, 235, 0.15);
--green: #22c55e;
--green-glow: rgba(34, 197, 94, 0.12);
--orange: #f97316;
--orange-glow: rgba(249, 115, 22, 0.12);
--red: #ef4444;
--red-glow: rgba(239, 68, 68, 0.12);
--cyan: #06b6d4;
--purple: #a78bfa;
--radius-sm: 6px;
--radius-md: 8px;
--radius-lg: 10px;
--transition: 150ms ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; } * { margin: 0; padding: 0; box-sizing: border-box; }
body { body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 13px; font-size: 13px;
color: #333; color: var(--text-primary);
background: #f8f9fa; background: var(--bg-base);
padding: 12px; padding: 12px;
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
-webkit-font-smoothing: antialiased;
} }
/* ============================================================
Header
============================================================ */
header { header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 12px; margin-bottom: 12px;
padding-bottom: 12px;
border-bottom: 1px solid var(--border-subtle);
} }
header h1 { .header-title {
font-size: 15px; display: flex;
font-weight: 600; align-items: center;
gap: 8px;
color: var(--text-primary);
}
.header-title svg { color: var(--blue); }
.header-title h1 {
font-size: 14px;
font-weight: 700;
letter-spacing: -0.02em;
} }
.header-btns { .header-btns {
@@ -28,195 +84,382 @@ header h1 {
gap: 6px; gap: 6px;
} }
#btn-reset { /* ============================================================
padding: 4px 10px; Buttons
font-size: 12px; ============================================================ */
background: #dc3545;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
#btn-reset:hover { background: #c82333; }
.btn-auto { .btn {
padding: 4px 10px; display: inline-flex;
font-size: 12px;
background: #28a745;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 600;
}
.btn-auto:hover { background: #218838; }
.btn-auto:disabled { background: #6c757d; cursor: not-allowed; }
.auto-continue-bar {
margin-top: 8px;
padding: 8px;
background: #fff3cd;
border: 1px solid #ffc107;
border-radius: 4px;
display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 5px;
} padding: 6px 12px;
font-family: inherit;
.auto-hint {
font-size: 11px;
color: #856404;
flex: 1;
}
.btn-continue {
padding: 4px 12px;
font-size: 12px; font-size: 12px;
background: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 600; font-weight: 600;
border: none;
border-radius: var(--radius-sm);
cursor: pointer;
transition: all var(--transition);
white-space: nowrap; white-space: nowrap;
} }
.btn-continue:hover { background: #0069d9; }
/* Data Section */ .btn-primary {
#data-section { background: var(--blue);
background: #fff; color: #fff;
border: 1px solid #dee2e6; }
border-radius: 6px; .btn-primary:hover { background: #3b82f6; box-shadow: 0 0 12px var(--blue-glow); }
padding: 10px;
margin-bottom: 12px; .btn-success {
background: var(--green);
color: #fff;
}
.btn-success:hover { background: #16a34a; box-shadow: 0 0 12px var(--green-glow); }
.btn-success:disabled { background: var(--bg-elevated); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
.btn-ghost {
background: transparent;
color: var(--text-secondary);
padding: 6px 8px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 2px 8px; font-size: 10px; }
/* ============================================================
Data Card
============================================================ */
#data-section { margin-bottom: 12px; }
.data-card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 10px 12px;
display: flex;
flex-direction: column;
gap: 8px;
} }
.data-row { .data-row {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 6px; gap: 8px;
} }
.data-row:last-child { margin-bottom: 0; }
.data-row label { .data-label {
width: 80px; width: 56px;
font-size: 11px;
font-weight: 600; font-weight: 600;
font-size: 12px; color: var(--text-muted);
color: #666; text-transform: uppercase;
letter-spacing: 0.04em;
flex-shrink: 0; flex-shrink: 0;
} }
.data-value { .data-value {
font-size: 12px; font-size: 11px;
color: #999; color: var(--text-secondary);
word-break: break-all; min-width: 0;
} }
.data-value.has-value { .data-value.has-value { color: var(--text-primary); }
color: #333;
.mono {
font-family: 'JetBrains Mono', 'Consolas', monospace;
font-size: 10.5px;
} }
#input-email { .truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.data-input {
flex: 1; flex: 1;
padding: 4px 8px; padding: 5px 8px;
border: 1px solid #ced4da; background: var(--bg-elevated);
border-radius: 4px; border: 1px solid var(--border);
font-size: 12px; border-radius: var(--radius-sm);
color: var(--text-primary);
font-family: 'JetBrains Mono', monospace;
font-size: 11px;
outline: none;
transition: border-color var(--transition);
min-width: 0;
}
.data-input::placeholder { color: var(--text-muted); }
.data-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-glow); }
/* Status Bar */
.status-bar {
display: flex;
align-items: center;
gap: 8px;
margin-top: 8px;
padding: 6px 10px;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-size: 11px;
color: var(--text-secondary);
} }
/* Steps Section */ .status-dot {
#steps-section { width: 6px;
margin-bottom: 12px; height: 6px;
border-radius: 50%;
background: var(--text-muted);
flex-shrink: 0;
}
.status-bar.running .status-dot {
background: var(--orange);
animation: pulse 1.5s ease-in-out infinite;
}
.status-bar.completed .status-dot { background: var(--green); }
.status-bar.failed .status-dot { background: var(--red); }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.3; }
}
/* Auto Continue Bar */
.auto-continue-bar {
margin-top: 8px;
padding: 8px 10px;
background: var(--orange-glow);
border: 1px solid rgba(249, 115, 22, 0.25);
border-radius: var(--radius-sm);
display: flex;
align-items: center;
gap: 8px;
}
.auto-continue-bar svg { color: var(--orange); flex-shrink: 0; }
.auto-hint {
font-size: 11px;
color: var(--orange);
flex: 1;
}
/* ============================================================
Steps Section
============================================================ */
#steps-section { margin-bottom: 12px; }
.steps-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.section-label {
font-size: 11px;
font-weight: 600;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.06em;
}
.steps-progress {
font-family: 'JetBrains Mono', monospace;
font-size: 11px;
color: var(--text-muted);
}
.steps-list {
display: flex;
flex-direction: column;
gap: 3px;
} }
.step-row { .step-row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin-bottom: 4px; padding: 2px 0;
transition: opacity var(--transition);
}
/* Step Number Indicator */
.step-indicator {
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--bg-elevated);
border: 1.5px solid var(--border);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
transition: all var(--transition);
} }
.step-num { .step-num {
width: 20px; font-size: 10px;
text-align: center;
font-weight: 600; font-weight: 600;
font-size: 12px; color: var(--text-muted);
color: #666;
} }
/* Step states via indicator */
.step-row.running .step-indicator {
border-color: var(--orange);
background: var(--orange-glow);
animation: pulse 1.5s ease-in-out infinite;
}
.step-row.running .step-num { color: var(--orange); }
.step-row.completed .step-indicator {
border-color: var(--green);
background: var(--green-glow);
}
.step-row.completed .step-num { color: var(--green); }
.step-row.failed .step-indicator {
border-color: var(--red);
background: var(--red-glow);
}
.step-row.failed .step-num { color: var(--red); }
/* Step Button */
.step-btn { .step-btn {
flex: 1; flex: 1;
padding: 6px 10px; padding: 6px 10px;
font-family: inherit;
font-size: 12px; font-size: 12px;
background: #007bff; font-weight: 500;
color: #fff; color: var(--text-primary);
border: none; background: var(--bg-surface);
border-radius: 4px; border: 1px solid var(--border);
border-radius: var(--radius-sm);
cursor: pointer; cursor: pointer;
text-align: left; text-align: left;
transition: all var(--transition);
} }
.step-btn:hover:not(:disabled) { background: #0069d9; }
.step-btn:hover:not(:disabled) {
background: var(--bg-hover);
border-color: var(--blue);
}
.step-btn:disabled { .step-btn:disabled {
background: #ccc; color: var(--text-muted);
background: var(--bg-base);
border-color: var(--border-subtle);
cursor: not-allowed; cursor: not-allowed;
opacity: 0.5;
} }
.step-row.running .step-btn {
border-color: var(--orange);
color: var(--orange);
}
.step-row.completed .step-btn {
border-color: var(--border-subtle);
color: var(--text-secondary);
}
.step-row.failed .step-btn {
border-color: var(--red);
color: var(--red);
}
/* Step Status Icon (right side) */
.step-status { .step-status {
width: 24px; width: 20px;
text-align: center; text-align: center;
font-size: 14px; font-size: 12px;
flex-shrink: 0;
} }
/* Log Section */ /* ============================================================
#log-section h2 { Log Section
font-size: 13px; ============================================================ */
font-weight: 600;
.log-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px; margin-bottom: 6px;
} }
#log-area { #log-area {
background: #1e1e1e; background: var(--bg-surface);
color: #d4d4d4; border: 1px solid var(--border);
font-family: 'Consolas', 'Courier New', monospace; border-radius: var(--radius-md);
font-size: 11px; padding: 8px 10px;
line-height: 1.5; height: 220px;
padding: 8px;
border-radius: 6px;
height: 250px;
overflow-y: auto; overflow-y: auto;
white-space: pre-wrap; font-family: 'JetBrains Mono', 'Consolas', monospace;
word-break: break-all; font-size: 10.5px;
line-height: 1.65;
color: var(--text-secondary);
} }
.log-info { color: #d4d4d4; } #log-area::-webkit-scrollbar { width: 4px; }
.log-ok { color: #4ec9b0; font-weight: bold; } #log-area::-webkit-scrollbar-track { background: transparent; }
.log-warn { color: #dcdcaa; } #log-area::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }
.log-error { color: #f44747; font-weight: bold; } #log-area::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
/* Log line styles */
.log-line { padding: 1px 0; }
.log-line + .log-line { border-top: 1px solid var(--border-subtle); }
.log-time { color: var(--text-muted); }
.log-level { font-weight: 600; }
.log-level-info { color: var(--blue); }
.log-level-ok { color: var(--green); }
.log-level-warn { color: var(--orange); }
.log-level-error { color: var(--red); }
.log-step-tag { .log-step-tag {
display: inline-block; display: inline-block;
background: #3a3d41;
color: #569cd6;
border-radius: 3px;
padding: 0 4px; padding: 0 4px;
margin-right: 4px; border-radius: 3px;
font-weight: bold; font-weight: 600;
font-size: 10px; font-size: 9.5px;
margin-right: 2px;
} }
.log-step-tag.step-1 { color: #4fc1ff; } .log-step-tag.step-1 { color: var(--cyan); background: rgba(6, 182, 212, 0.1); }
.log-step-tag.step-2 { color: #c586c0; } .log-step-tag.step-2 { color: var(--purple); background: rgba(167, 139, 250, 0.1); }
.log-step-tag.step-3 { color: #dcdcaa; } .log-step-tag.step-3 { color: #facc15; background: rgba(250, 204, 21, 0.1); }
.log-step-tag.step-4 { color: #ce9178; } .log-step-tag.step-4 { color: var(--orange); background: var(--orange-glow); }
.log-step-tag.step-5 { color: #b5cea8; } .log-step-tag.step-5 { color: var(--green); background: var(--green-glow); }
.log-step-tag.step-6 { color: #4fc1ff; } .log-step-tag.step-6 { color: var(--cyan); background: rgba(6, 182, 212, 0.1); }
.log-step-tag.step-7 { color: #ce9178; } .log-step-tag.step-7 { color: var(--orange); background: var(--orange-glow); }
.log-step-tag.step-8 { color: #c586c0; } .log-step-tag.step-8 { color: var(--purple); background: rgba(167, 139, 250, 0.1); }
.log-step-tag.step-9 { color: #b5cea8; } .log-step-tag.step-9 { color: var(--green); background: var(--green-glow); }
.log-time { color: #6a9955; } .log-msg { color: var(--text-secondary); }
.log-level { font-weight: bold; } .log-line.log-ok .log-msg { color: var(--green); }
.log-level-info { color: #569cd6; } .log-line.log-error .log-msg { color: var(--red); }
.log-level-ok { color: #4ec9b0; } .log-line.log-warn .log-msg { color: var(--orange); }
.log-level-warn { color: #dcdcaa; }
.log-level-error { color: #f44747; } /* ============================================================
Animations
============================================================ */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}
.log-line { animation: fadeIn 150ms ease-out; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
+90 -63
View File
@@ -4,90 +4,117 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Page Automation</title> <title>Multi-Page Automation</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="sidepanel.css"> <link rel="stylesheet" href="sidepanel.css">
</head> </head>
<body> <body>
<header> <header>
<h1>Multi-Page Automation</h1> <div class="header-title">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/>
</svg>
<h1>MultiPage</h1>
</div>
<div class="header-btns"> <div class="header-btns">
<button id="btn-auto-run" class="btn-auto" title="Run all steps automatically">Auto Run</button> <button id="btn-auto-run" class="btn btn-success" title="Run all steps automatically">
<button id="btn-reset" title="Reset all steps">Reset</button> <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
Auto
</button>
<button id="btn-reset" class="btn btn-ghost" title="Reset all steps">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>
</svg>
</button>
</div> </div>
</header> </header>
<section id="data-section"> <section id="data-section">
<div class="data-row"> <div class="data-card">
<label>OAuth URL:</label> <div class="data-row">
<span id="display-oauth-url" class="data-value">Not obtained</span> <span class="data-label">OAuth</span>
<span id="display-oauth-url" class="data-value mono truncate">Waiting...</span>
</div>
<div class="data-row">
<span class="data-label">Email</span>
<input type="text" id="input-email" class="data-input" placeholder="Paste DuckDuckGo email" />
</div>
<div class="data-row">
<span class="data-label">Callback</span>
<span id="display-localhost-url" class="data-value mono truncate">Waiting...</span>
</div>
</div> </div>
<div class="data-row"> <div id="status-bar" class="status-bar">
<label>Email:</label> <div class="status-dot"></div>
<input type="text" id="input-email" placeholder="Paste DuckDuckGo email here" /> <span id="display-status">Ready</span>
</div>
<div class="data-row">
<label>Localhost:</label>
<span id="display-localhost-url" class="data-value">Not captured</span>
</div>
<div class="data-row">
<label>Status:</label>
<span id="display-status" class="data-value">Waiting</span>
</div> </div>
<div id="auto-continue-bar" class="auto-continue-bar" style="display:none;"> <div id="auto-continue-bar" class="auto-continue-bar" style="display:none;">
<span class="auto-hint">Paste DuckDuckGo email above, then:</span> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<button id="btn-auto-continue" class="btn-continue">Continue Auto</button> <span class="auto-hint">Paste email above, then continue</span>
<button id="btn-auto-continue" class="btn btn-primary btn-sm">Continue</button>
</div> </div>
</section> </section>
<section id="steps-section"> <section id="steps-section">
<div class="step-row" data-step="1"> <div class="steps-header">
<span class="step-num">1</span> <span class="section-label">Workflow</span>
<button class="step-btn" data-step="1">Get OAuth Link</button> <span id="steps-progress" class="steps-progress">0 / 9</span>
<span class="step-status" data-step="1"></span>
</div> </div>
<div class="step-row" data-step="2"> <div class="steps-list">
<span class="step-num">2</span> <div class="step-row" data-step="1">
<button class="step-btn" data-step="2">Open Signup</button> <div class="step-indicator" data-step="1"><span class="step-num">1</span></div>
<span class="step-status" data-step="2"></span> <button class="step-btn" data-step="1">Get OAuth Link</button>
</div> <span class="step-status" data-step="1"></span>
<div class="step-row" data-step="3"> </div>
<span class="step-num">3</span> <div class="step-row" data-step="2">
<button class="step-btn" data-step="3">Fill Email/Password</button> <div class="step-indicator" data-step="2"><span class="step-num">2</span></div>
<span class="step-status" data-step="3"></span> <button class="step-btn" data-step="2">Open Signup</button>
</div> <span class="step-status" data-step="2"></span>
<div class="step-row" data-step="4"> </div>
<span class="step-num">4</span> <div class="step-row" data-step="3">
<button class="step-btn" data-step="4">Get Signup Code</button> <div class="step-indicator" data-step="3"><span class="step-num">3</span></div>
<span class="step-status" data-step="4"></span> <button class="step-btn" data-step="3">Fill Email / Password</button>
</div> <span class="step-status" data-step="3"></span>
<div class="step-row" data-step="5"> </div>
<span class="step-num">5</span> <div class="step-row" data-step="4">
<button class="step-btn" data-step="5">Fill Name/Birthday</button> <div class="step-indicator" data-step="4"><span class="step-num">4</span></div>
<span class="step-status" data-step="5"></span> <button class="step-btn" data-step="4">Get Signup Code</button>
</div> <span class="step-status" data-step="4"></span>
<div class="step-row" data-step="6"> </div>
<span class="step-num">6</span> <div class="step-row" data-step="5">
<button class="step-btn" data-step="6">Login ChatGPT</button> <div class="step-indicator" data-step="5"><span class="step-num">5</span></div>
<span class="step-status" data-step="6"></span> <button class="step-btn" data-step="5">Fill Name / Birthday</button>
</div> <span class="step-status" data-step="5"></span>
<div class="step-row" data-step="7"> </div>
<span class="step-num">7</span> <div class="step-row" data-step="6">
<button class="step-btn" data-step="7">Get Login Code</button> <div class="step-indicator" data-step="6"><span class="step-num">6</span></div>
<span class="step-status" data-step="7"></span> <button class="step-btn" data-step="6">Login via OAuth</button>
</div> <span class="step-status" data-step="6"></span>
<div class="step-row" data-step="8"> </div>
<span class="step-num">8</span> <div class="step-row" data-step="7">
<button class="step-btn" data-step="8">Complete OAuth</button> <div class="step-indicator" data-step="7"><span class="step-num">7</span></div>
<span class="step-status" data-step="8"></span> <button class="step-btn" data-step="7">Get Login Code</button>
</div> <span class="step-status" data-step="7"></span>
<div class="step-row" data-step="9"> </div>
<span class="step-num">9</span> <div class="step-row" data-step="8">
<button class="step-btn" data-step="9">VPS Verify</button> <div class="step-indicator" data-step="8"><span class="step-num">8</span></div>
<span class="step-status" data-step="9"></span> <button class="step-btn" data-step="8">Complete OAuth</button>
<span class="step-status" data-step="8"></span>
</div>
<div class="step-row" data-step="9">
<div class="step-indicator" data-step="9"><span class="step-num">9</span></div>
<button class="step-btn" data-step="9">VPS Verify</button>
<span class="step-status" data-step="9"></span>
</div>
</div> </div>
</section> </section>
<section id="log-section"> <section id="log-section">
<h2>Log</h2> <div class="log-header">
<span class="section-label">Console</span>
<button id="btn-clear-log" class="btn btn-ghost btn-xs" title="Clear log">Clear</button>
</div>
<div id="log-area"></div> <div id="log-area"></div>
</section> </section>
+98 -82
View File
@@ -1,18 +1,24 @@
// sidepanel/sidepanel.js — Side Panel logic // sidepanel/sidepanel.js — Side Panel logic
const STATUS_ICONS = { const STATUS_ICONS = {
pending: '\u2B1A', // ⬚ pending: '',
running: '\u23F3', // ⏳ running: '',
completed: '\u2705', // completed: '\u2713', //
failed: '\u274C', // failed: '\u2717', //
}; };
const logArea = document.getElementById('log-area'); const logArea = document.getElementById('log-area');
const displayOauthUrl = document.getElementById('display-oauth-url'); const displayOauthUrl = document.getElementById('display-oauth-url');
const displayLocalhostUrl = document.getElementById('display-localhost-url'); const displayLocalhostUrl = document.getElementById('display-localhost-url');
const displayStatus = document.getElementById('display-status'); const displayStatus = document.getElementById('display-status');
const statusBar = document.getElementById('status-bar');
const inputEmail = document.getElementById('input-email'); const inputEmail = document.getElementById('input-email');
const btnReset = document.getElementById('btn-reset'); const btnReset = document.getElementById('btn-reset');
const stepsProgress = document.getElementById('steps-progress');
const btnAutoRun = document.getElementById('btn-auto-run');
const btnAutoContinue = document.getElementById('btn-auto-continue');
const autoContinueBar = document.getElementById('auto-continue-bar');
const btnClearLog = document.getElementById('btn-clear-log');
// ============================================================ // ============================================================
// State Restore on load // State Restore on load
@@ -22,7 +28,6 @@ async function restoreState() {
try { try {
const state = await chrome.runtime.sendMessage({ type: 'GET_STATE', source: 'sidepanel' }); const state = await chrome.runtime.sendMessage({ type: 'GET_STATE', source: 'sidepanel' });
// Restore data fields
if (state.oauthUrl) { if (state.oauthUrl) {
displayOauthUrl.textContent = state.oauthUrl; displayOauthUrl.textContent = state.oauthUrl;
displayOauthUrl.classList.add('has-value'); displayOauthUrl.classList.add('has-value');
@@ -35,14 +40,12 @@ async function restoreState() {
inputEmail.value = state.email; inputEmail.value = state.email;
} }
// Restore step statuses
if (state.stepStatuses) { if (state.stepStatuses) {
for (const [step, status] of Object.entries(state.stepStatuses)) { for (const [step, status] of Object.entries(state.stepStatuses)) {
updateStepUI(Number(step), status); updateStepUI(Number(step), status);
} }
} }
// Restore logs
if (state.logs) { if (state.logs) {
for (const entry of state.logs) { for (const entry of state.logs) {
appendLog(entry); appendLog(entry);
@@ -50,6 +53,7 @@ async function restoreState() {
} }
updateStatusDisplay(state); updateStatusDisplay(state);
updateProgressCounter();
} catch (err) { } catch (err) {
console.error('Failed to restore state:', err); console.error('Failed to restore state:', err);
} }
@@ -61,23 +65,36 @@ async function restoreState() {
function updateStepUI(step, status) { function updateStepUI(step, status) {
const statusEl = document.querySelector(`.step-status[data-step="${step}"]`); const statusEl = document.querySelector(`.step-status[data-step="${step}"]`);
if (statusEl) statusEl.textContent = STATUS_ICONS[status] || '\u2B1A'; const row = document.querySelector(`.step-row[data-step="${step}"]`);
const indicator = document.querySelector(`.step-indicator[data-step="${step}"]`);
if (statusEl) statusEl.textContent = STATUS_ICONS[status] || '';
if (row) {
row.className = `step-row ${status}`;
}
// Interlock logic
updateButtonStates(); updateButtonStates();
updateProgressCounter();
}
function updateProgressCounter() {
let completed = 0;
document.querySelectorAll('.step-row').forEach(row => {
if (row.classList.contains('completed')) completed++;
});
stepsProgress.textContent = `${completed} / 9`;
} }
function updateButtonStates() { function updateButtonStates() {
// Get all current statuses from DOM
const statuses = {}; const statuses = {};
document.querySelectorAll('.step-status').forEach(el => { document.querySelectorAll('.step-row').forEach(row => {
const step = Number(el.dataset.step); const step = Number(row.dataset.step);
const icon = el.textContent; if (row.classList.contains('completed')) statuses[step] = 'completed';
const status = Object.entries(STATUS_ICONS).find(([, v]) => v === icon)?.[0] || 'pending'; else if (row.classList.contains('running')) statuses[step] = 'running';
statuses[step] = status; else if (row.classList.contains('failed')) statuses[step] = 'failed';
else statuses[step] = 'pending';
}); });
// Find if any step is running
const anyRunning = Object.values(statuses).some(s => s === 'running'); const anyRunning = Object.values(statuses).some(s => s === 'running');
for (let step = 1; step <= 9; step++) { for (let step = 1; step <= 9; step++) {
@@ -85,13 +102,10 @@ function updateButtonStates() {
if (!btn) continue; if (!btn) continue;
if (anyRunning) { if (anyRunning) {
// When any step is running, disable all buttons
btn.disabled = true; btn.disabled = true;
} else if (step === 1) { } else if (step === 1) {
// Step 1 is always available (unless running)
btn.disabled = false; btn.disabled = false;
} else { } else {
// Steps 2-9: enabled if previous step completed (or current step failed for retry)
const prevStatus = statuses[step - 1]; const prevStatus = statuses[step - 1];
const currentStatus = statuses[step]; const currentStatus = statuses[step];
btn.disabled = !(prevStatus === 'completed' || currentStatus === 'failed' || currentStatus === 'completed'); btn.disabled = !(prevStatus === 'completed' || currentStatus === 'failed' || currentStatus === 'completed');
@@ -101,45 +115,53 @@ function updateButtonStates() {
function updateStatusDisplay(state) { function updateStatusDisplay(state) {
if (!state || !state.stepStatuses) return; if (!state || !state.stepStatuses) return;
statusBar.className = 'status-bar';
const running = Object.entries(state.stepStatuses).find(([, s]) => s === 'running'); const running = Object.entries(state.stepStatuses).find(([, s]) => s === 'running');
if (running) { if (running) {
displayStatus.textContent = `Step ${running[0]} running...`; displayStatus.textContent = `Step ${running[0]} running...`;
displayStatus.classList.add('has-value'); statusBar.classList.add('running');
return;
}
const failed = Object.entries(state.stepStatuses).find(([, s]) => s === 'failed');
if (failed) {
displayStatus.textContent = `Step ${failed[0]} failed`;
statusBar.classList.add('failed');
return;
}
const lastCompleted = Object.entries(state.stepStatuses)
.filter(([, s]) => s === 'completed')
.map(([k]) => Number(k))
.sort((a, b) => b - a)[0];
if (lastCompleted === 9) {
displayStatus.textContent = 'All steps completed!';
statusBar.classList.add('completed');
} else if (lastCompleted) {
displayStatus.textContent = `Step ${lastCompleted} done`;
} else { } else {
const lastCompleted = Object.entries(state.stepStatuses) displayStatus.textContent = 'Ready';
.filter(([, s]) => s === 'completed')
.map(([k]) => Number(k))
.sort((a, b) => b - a)[0];
if (lastCompleted === 9) {
displayStatus.textContent = 'All steps completed!';
displayStatus.classList.add('has-value');
} else if (lastCompleted) {
displayStatus.textContent = `Step ${lastCompleted} done. Ready for step ${lastCompleted + 1}.`;
displayStatus.classList.add('has-value');
} else {
displayStatus.textContent = 'Waiting';
displayStatus.classList.remove('has-value');
}
} }
} }
function appendLog(entry) { function appendLog(entry) {
const time = new Date(entry.timestamp).toLocaleTimeString('en-US', { hour12: false }); const time = new Date(entry.timestamp).toLocaleTimeString('en-US', { hour12: false });
const levelLabel = entry.level.toUpperCase().padEnd(5); const levelLabel = entry.level.toUpperCase();
const line = document.createElement('div'); const line = document.createElement('div');
line.className = `log-${entry.level}`; line.className = `log-line log-${entry.level}`;
// Extract step number from message (e.g., "Step 4: ..." or "[vps-panel] Step 1: ...")
const stepMatch = entry.message.match(/Step (\d)/); const stepMatch = entry.message.match(/Step (\d)/);
const stepNum = stepMatch ? stepMatch[1] : null; const stepNum = stepMatch ? stepMatch[1] : null;
// Build rich HTML
let html = `<span class="log-time">${time}</span> `; let html = `<span class="log-time">${time}</span> `;
html += `<span class="log-level log-level-${entry.level}">[${levelLabel}]</span> `; html += `<span class="log-level log-level-${entry.level}">${levelLabel}</span> `;
if (stepNum) { if (stepNum) {
html += `<span class="log-step-tag step-${stepNum}">S${stepNum}</span>`; html += `<span class="log-step-tag step-${stepNum}">S${stepNum}</span>`;
} }
html += `<span>${escapeHtml(entry.message)}</span>`; html += `<span class="log-msg">${escapeHtml(entry.message)}</span>`;
line.innerHTML = html; line.innerHTML = html;
logArea.appendChild(line); logArea.appendChild(line);
@@ -159,37 +181,23 @@ function escapeHtml(text) {
document.querySelectorAll('.step-btn').forEach(btn => { document.querySelectorAll('.step-btn').forEach(btn => {
btn.addEventListener('click', async () => { btn.addEventListener('click', async () => {
const step = Number(btn.dataset.step); const step = Number(btn.dataset.step);
// Save email if step 3 and email input has value
if (step === 3) { if (step === 3) {
const email = inputEmail.value.trim(); const email = inputEmail.value.trim();
if (!email) { if (!email) {
appendLog({ message: 'Please paste email address first', level: 'error', timestamp: Date.now() }); appendLog({ message: 'Please paste email address first', level: 'error', timestamp: Date.now() });
return; return;
} }
await chrome.runtime.sendMessage({ await chrome.runtime.sendMessage({ type: 'EXECUTE_STEP', source: 'sidepanel', payload: { step, email } });
type: 'EXECUTE_STEP',
source: 'sidepanel',
payload: { step, email },
});
} else { } else {
await chrome.runtime.sendMessage({ await chrome.runtime.sendMessage({ type: 'EXECUTE_STEP', source: 'sidepanel', payload: { step } });
type: 'EXECUTE_STEP',
source: 'sidepanel',
payload: { step },
});
} }
}); });
}); });
// Auto Run button // Auto Run
const btnAutoRun = document.getElementById('btn-auto-run');
const btnAutoContinue = document.getElementById('btn-auto-continue');
const autoContinueBar = document.getElementById('auto-continue-bar');
btnAutoRun.addEventListener('click', async () => { btnAutoRun.addEventListener('click', async () => {
btnAutoRun.disabled = true; btnAutoRun.disabled = true;
btnAutoRun.textContent = 'Running...'; btnAutoRun.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg> Running...';
await chrome.runtime.sendMessage({ type: 'AUTO_RUN', source: 'sidepanel' }); await chrome.runtime.sendMessage({ type: 'AUTO_RUN', source: 'sidepanel' });
}); });
@@ -200,44 +208,41 @@ btnAutoContinue.addEventListener('click', async () => {
return; return;
} }
autoContinueBar.style.display = 'none'; autoContinueBar.style.display = 'none';
btnAutoRun.textContent = 'Running...'; await chrome.runtime.sendMessage({ type: 'RESUME_AUTO_RUN', source: 'sidepanel', payload: { email } });
await chrome.runtime.sendMessage({
type: 'RESUME_AUTO_RUN',
source: 'sidepanel',
payload: { email },
});
}); });
// Reset button // Reset
btnReset.addEventListener('click', async () => { btnReset.addEventListener('click', async () => {
if (confirm('Reset all steps and data?')) { if (confirm('Reset all steps and data?')) {
await chrome.runtime.sendMessage({ type: 'RESET', source: 'sidepanel' }); await chrome.runtime.sendMessage({ type: 'RESET', source: 'sidepanel' });
// Clear UI displayOauthUrl.textContent = 'Waiting...';
displayOauthUrl.textContent = 'Not obtained';
displayOauthUrl.classList.remove('has-value'); displayOauthUrl.classList.remove('has-value');
displayLocalhostUrl.textContent = 'Not captured'; displayLocalhostUrl.textContent = 'Waiting...';
displayLocalhostUrl.classList.remove('has-value'); displayLocalhostUrl.classList.remove('has-value');
inputEmail.value = ''; inputEmail.value = '';
displayStatus.textContent = 'Waiting'; displayStatus.textContent = 'Ready';
displayStatus.classList.remove('has-value'); statusBar.className = 'status-bar';
logArea.innerHTML = ''; logArea.innerHTML = '';
document.querySelectorAll('.step-status').forEach(el => el.textContent = '\u2B1A'); document.querySelectorAll('.step-row').forEach(row => row.className = 'step-row');
document.querySelectorAll('.step-status').forEach(el => el.textContent = '');
btnAutoRun.disabled = false; btnAutoRun.disabled = false;
btnAutoRun.textContent = 'Auto Run'; btnAutoRun.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg> Auto';
autoContinueBar.style.display = 'none'; autoContinueBar.style.display = 'none';
updateButtonStates(); updateButtonStates();
updateProgressCounter();
} }
}); });
// Save email when user types/pastes // Clear log
btnClearLog.addEventListener('click', () => {
logArea.innerHTML = '';
});
// Save email on change
inputEmail.addEventListener('change', async () => { inputEmail.addEventListener('change', async () => {
const email = inputEmail.value.trim(); const email = inputEmail.value.trim();
if (email) { if (email) {
await chrome.runtime.sendMessage({ await chrome.runtime.sendMessage({ type: 'SAVE_EMAIL', source: 'sidepanel', payload: { email } });
type: 'SAVE_EMAIL',
source: 'sidepanel',
payload: { email },
});
} }
}); });
@@ -254,8 +259,19 @@ chrome.runtime.onMessage.addListener((message) => {
case 'STEP_STATUS_CHANGED': { case 'STEP_STATUS_CHANGED': {
const { step, status } = message.payload; const { step, status } = message.payload;
updateStepUI(step, status); updateStepUI(step, status);
// Update status display
chrome.runtime.sendMessage({ type: 'GET_STATE', source: 'sidepanel' }).then(updateStatusDisplay); chrome.runtime.sendMessage({ type: 'GET_STATE', source: 'sidepanel' }).then(updateStatusDisplay);
if (status === 'completed') {
chrome.runtime.sendMessage({ type: 'GET_STATE', source: 'sidepanel' }).then(state => {
if (state.oauthUrl) {
displayOauthUrl.textContent = state.oauthUrl;
displayOauthUrl.classList.add('has-value');
}
if (state.localhostUrl) {
displayLocalhostUrl.textContent = state.localhostUrl;
displayLocalhostUrl.classList.add('has-value');
}
});
}
break; break;
} }
@@ -276,16 +292,16 @@ chrome.runtime.onMessage.addListener((message) => {
switch (phase) { switch (phase) {
case 'waiting_email': case 'waiting_email':
autoContinueBar.style.display = 'flex'; autoContinueBar.style.display = 'flex';
btnAutoRun.textContent = 'Waiting...'; btnAutoRun.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg> Paused';
break; break;
case 'complete': case 'complete':
btnAutoRun.disabled = false; btnAutoRun.disabled = false;
btnAutoRun.textContent = 'Auto Run'; btnAutoRun.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg> Auto';
autoContinueBar.style.display = 'none'; autoContinueBar.style.display = 'none';
break; break;
case 'stopped': case 'stopped':
btnAutoRun.disabled = false; btnAutoRun.disabled = false;
btnAutoRun.textContent = 'Auto Run'; btnAutoRun.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg> Auto';
autoContinueBar.style.display = 'none'; autoContinueBar.style.display = 'none';
break; break;
} }