From b26e9473f2242ded84bb4672aa801cfbf83da8a8 Mon Sep 17 00:00:00 2001 From: wrt122311 <1720122311@qq.com> Date: Fri, 24 Apr 2026 12:28:54 +0800 Subject: [PATCH] feat: add selected images panel and clear-all button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New "已选" tab shows all selected images in a grid; each card has an X button (top-right) to remove that image from the selection - "清除全部" button in header clears all selections at once - illustCache persists illust thumbnails across modal opens so the panel can display images selected in previous sessions Co-Authored-By: Claude Sonnet 4.6 --- web/pixiv_dialog.css | 32 ++++++++++++++++ web/pixiv_extension.js | 85 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/web/pixiv_dialog.css b/web/pixiv_dialog.css index 625e1a5..21a19bc 100644 --- a/web/pixiv_dialog.css +++ b/web/pixiv_dialog.css @@ -168,6 +168,38 @@ text-overflow: ellipsis; } +#pixiv-clear-all-btn { + padding: 4px 10px; + background: transparent; + border: 1px solid #45475a; + color: #7f849c; + border-radius: 4px; + cursor: pointer; + font-size: 12px; +} +#pixiv-clear-all-btn:hover { color: #f38ba8; border-color: #f38ba8; } + +.pixiv-card-remove-btn { + position: absolute; + top: 4px; + right: 4px; + background: rgba(243, 139, 168, 0.85); + color: #1e1e2e; + border: none; + border-radius: 50%; + width: 20px; + height: 20px; + display: flex; + align-items: center; + justify-content: center; + font-size: 11px; + font-weight: bold; + cursor: pointer; + line-height: 1; + padding: 0; +} +.pixiv-card-remove-btn:hover { background: #f38ba8; } + .pixiv-seq-badge { position: absolute; top: 4px; diff --git a/web/pixiv_extension.js b/web/pixiv_extension.js index 5873bb9..da092c7 100644 --- a/web/pixiv_extension.js +++ b/web/pixiv_extension.js @@ -11,6 +11,9 @@ const state = { artistNextUrl: null, }; +// Persists across modal opens so the "已选" panel can show thumbnails +const illustCache = new Map(); + // ── CSS injection ───────────────────────────────────────────────────────────── function injectCSS() { @@ -34,6 +37,9 @@ function escapeHtml(str) { function updateSelectedCount() { const el = document.getElementById("pixiv-selected-count"); if (el) el.textContent = `已选 ${state.selectedIds.length} 张`; + const tabEl = document.getElementById("pixiv-selected-tab"); + if (tabEl) tabEl.textContent = state.selectedIds.length > 0 + ? `已选 (${state.selectedIds.length})` : "已选"; } // ── Modal DOM ───────────────────────────────────────────────────────────────── @@ -46,6 +52,7 @@ function buildModal() {

📷 Pixiv Browser

已选 0 张 +
@@ -53,6 +60,7 @@ function buildModal() { +