Skip to content
Merged
Show file tree
Hide file tree
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
67 changes: 43 additions & 24 deletions docs/DESIGN.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/TRIAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- **保留**只在 MoonDigest 里标记,B站收藏夹不变,视频留在原来的页签。**取消收藏**会真的在 B站取消,按 U 可以撤销;取消收藏的视频不在这些页签里,去「已出分拣范围」。
- 第 3 行(状态)的「已保留」是你保留过的;「待决定」是还没保留的,后面框里的「值得留 / 可清理 / 拿不准」是 AI 对它们的判断。一次选一个。保留过的视频不再按 AI 判断分。第 4 行(标签)开头是它自己的「全部」和「未打标签 / 已打标签」。两行的「全部」各清各的。
- 「字幕细看下一批」跳过已保留的视频,省 AI 的钱;想细看已保留的,选中再点。
- 第 3 行按 AI 判断的批量按钮(如「取消收藏(AI:可清理)」)只动待决定的视频,不碰你保留过的;想取消收藏已保留的,选中再点「取消收藏选中的 N 个」。
- 第 3 行按 AI 判断的批量按钮(如「取消收藏(AI:可清理)」)只动待决定的视频,不碰你保留过的;想取消收藏已保留的,选中再点选中栏的「取消收藏」。
- 每张卡片 AI 判断那一行有一个按钮,只跑这一个视频:粗看过的是 **✦ 字幕细看**,细看过的是 **✦ 重新细看**。重新细看跳过缓存再跑一次,用在某次摘要明显不好时;想让整个收藏夹换个写法,改判断标准再「按新标准重新细看」,只想问这一个视频,按 Q 问 AI。
- 细看时视频没有字幕,AI 按简介和热门评论判断,卡片上标灰色的「无字幕」(没登录 B站时是「未登录无字幕」,字幕下载失败是「字幕抓取失败」,悬停看原因)。第 3 行的「无字幕」筛选能把它们挑出来。
- 粗看、细看、批量取消收藏和移动在切换收藏夹后继续跑,进度显示在进度胶囊里。关掉分拣台页面就暂停。
Expand Down
2 changes: 1 addition & 1 deletion extension/bili-surfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
space: "UP 空间的视频卡"
};
const { LABEL } = MdgErrors;
const COLS = { verdict: LABEL.aiVerdict, vtags: LABEL.videoTags, ups: "UP 标签", plus: "「+ UP 标签」", seen: LABEL.seen };
const COLS = { verdict: LABEL.aiVerdict, vtags: LABEL.videoTags, ups: LABEL.upTags, plus: LABEL.upTagAdd, seen: LABEL.seen };
// Which cells a surface offers; the others are not for the user to turn on.
function allowed(key, col) {
const r = SURFACES[key];
Expand Down
3 changes: 2 additions & 1 deletion extension/content-tokens.selftest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const rules = (css) =>
body,
vars: new Map([...body.matchAll(/(--[\w-]+)\s*:\s*([^;]+);/g)].map(([, k, v]) => [k, v.trim().replace(/\s+/g, " ")]))
}));
const asMdg = (vars) => new Map([...vars].map(([k, v]) => [`--mdg-${k.slice(2)}`, v]));
// A token made of another token (--focus-ring from --text-2) names the mirrored one there.
const asMdg = (vars) => new Map([...vars].map(([k, v]) => [`--mdg-${k.slice(2)}`, v.replace(/var\(--/g, "var(--mdg-")]));
const pick = (vars, prefix) => new Map([...vars].filter(([k]) => k.startsWith(prefix)));

const tokenRules = rules(read("tokens.css")).filter((r) => r.selector === ":root");
Expand Down
14 changes: 7 additions & 7 deletions extension/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
--mdg-muted: #61666d;
--mdg-faint: #6d7279;
--mdg-accent: #ff6699;
--mdg-focus-ring: rgba(255, 102, 153, 0.3);
--mdg-action: #00aeec;
--mdg-action-hover: #0098ce;
--mdg-on-action: #ffffff;
Expand Down Expand Up @@ -65,6 +64,7 @@
--mdg-cover-scrim: rgba(0, 0, 0, 0.6);
--mdg-shadow-float: 0 4px 16px rgba(0, 0, 0, 0.15);
--mdg-lift: 0 8px 22px rgba(0, 0, 0, 0.14);
--mdg-focus-ring: 0 0 0 3px color-mix(in srgb, var(--mdg-text-2) 18%, transparent);
--mdg-backdrop: rgba(17, 24, 39, 0.28);
}

Expand All @@ -83,7 +83,6 @@ html[data-mdg-reader-mode="1"][data-mdg-reader-theme="dark"] {
--mdg-muted: #a2a7ae;
--mdg-faint: #8a8f96;
--mdg-accent: #ff6699;
--mdg-focus-ring: rgba(255, 102, 153, 0.35);
--mdg-action: #00aeec;
--mdg-action-hover: #33bef0;
--mdg-on-action: #ffffff;
Expand Down Expand Up @@ -124,7 +123,6 @@ html[data-mdg-reader-mode="1"][data-mdg-reader-theme="dark"] {
--mdg-muted: #a2a7ae;
--mdg-faint: #8a8f96;
--mdg-accent: #ff6699;
--mdg-focus-ring: rgba(255, 102, 153, 0.35);
--mdg-action: #00aeec;
--mdg-action-hover: #33bef0;
--mdg-on-action: #ffffff;
Expand Down Expand Up @@ -155,14 +153,16 @@ html[data-mdg-reader-mode="1"][data-mdg-reader-theme="dark"] {
}

:where(#mdg-root, .mdg-confirm-overlay, #mdg-reading-inline-host) :where(button, select, textarea, input, summary, a):focus-visible {
outline: 2px solid var(--mdg-accent);
outline-offset: 2px;
outline: 1px solid var(--mdg-text-2);
outline-offset: -1px;
box-shadow: var(--mdg-focus-ring);
}
:where(#mdg-root, .mdg-confirm-overlay, #mdg-reading-inline-host) :where(a):focus-visible { outline-offset: 2px; border-radius: 4px; box-shadow: none; }

:where(#mdg-root, .mdg-confirm-overlay, #mdg-reading-inline-host) :where(select, textarea, input[type="text"]):focus-visible {
outline: none;
border-color: var(--mdg-accent);
box-shadow: 0 0 0 3px var(--mdg-focus-ring);
border-color: var(--mdg-text-2);
box-shadow: var(--mdg-focus-ring);
}

.mdg-confirm-cancel {
Expand Down
7 changes: 6 additions & 1 deletion extension/dev-sidepanel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MoonDigest · AI 侧边栏</title>
<link rel="stylesheet" href="../tokens.css" />
<link rel="stylesheet" href="../vendor/Temml-Local.css" />
<link rel="stylesheet" href="../sidepanel.css" />
</head>
<body>
Expand Down Expand Up @@ -34,6 +35,7 @@
<section id="spNote" class="sp-note" hidden>
<button id="spNoteToggle" type="button" class="sp-note-toggle is-empty" title="这个视频的备注,和分拣台、摘读记录里的是同一份"><span class="sp-note-label"><span class="sp-note-add" data-text="noteAdd">✎ 备注</span><span class="sp-note-head" data-text="noteAdd">✎ 备注</span></span><span id="spNoteText" class="sp-note-text"></span></button>
<textarea id="spNoteInput" class="sp-note-input" rows="2" placeholder="一句话备注,回车保存" aria-label="备注" hidden data-text="notePlaceholder"></textarea>
<p class="sp-note-keys">回车或 Esc 保存 · Shift+回车换行</p>
</section>
<div class="sp-center-error" aria-busy="true" data-text="loading">正在加载…</div>
<div class="sp-suggestions" id="spSuggestions"></div>
Expand All @@ -57,7 +59,8 @@
<span>管理快捷追问</span>
</button>
<div id="spPresetPopover" class="sp-preset-popover" hidden>
<div id="spPresetList" class="sp-preset-list"></div>
<div class="sp-preset-head"><span class="sp-pop-title">管理快捷追问</span><span id="spPresetCount" class="sp-preset-count"></span></div>
<ul id="spPresetList" class="sp-preset-list"></ul>
<div class="sp-preset-editor">
<input id="spPresetInput" class="sp-preset-input" type="text" placeholder="添加快捷追问" />
<button id="spPresetAddBtn" type="button" class="sp-preset-add-btn">添加</button>
Expand Down Expand Up @@ -86,6 +89,7 @@
</div>
<div id="spHistoryPopover" class="sp-history-popover" hidden>
<div class="sp-history-popover-head">
<span class="sp-pop-title">历史对话</span>
<a class="sp-history-manage" href="./history/history.html" target="_blank" title="打开摘读记录" aria-label="打开摘读记录" data-text="history">摘读记录</a>
</div>
<div id="spHistoryList" class="sp-history-list"></div>
Expand All @@ -110,6 +114,7 @@
<script src="../typing.js"></script>
<script src="../sites.js"></script>
<script src="../tag-core.js"></script>
<script src="../vendor/temml.min.js"></script>
<script src="../note.js"></script>
<script src="../download.js"></script>
<script src="../note-actions.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions extension/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,20 @@
// B站 pages' columns, 摘读记录 and the 收藏夹 CSV.
aiVerdict: "AI 判断",
videoTags: "视频标签",
// The tags on an UP (not 「UP 主标签」), and B站 pages' button that adds one.
upTags: "UP 标签",
upTagAdd: "「+ UP 标签」",
// Note properties: 专注模式's info line, the settings page, the popup's 详情.
uploadDate: "发布日期",
exportDate: "导出日期",
// Opens the 备注 box (side panel, 摘读记录, 分拣台).
noteAdd: "✎ 备注",
// The help dialogs (分拣台's two, 摘读记录) and the buttons they name.
shortcuts: "快捷键",
keysMove: "移动和选中",
keysCard: "当前卡片",
keyPrevCard: "上一张卡片",
keyTag: "打标签",
keyTagNumber: "打标签时勾选或去掉第几个标签",
keySearch: "搜索(Esc 清空)",
keyHelp: "显示本帮助",
Expand Down
54 changes: 41 additions & 13 deletions extension/history/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,35 @@ <h2 id="tagPickerTitle" class="tp-title"></h2>
<p class="tp-note dialog-meta"></p>
<input id="tagPickerInput" name="tagQuery" class="tp-input" type="text" autocomplete="off" />
<ul class="picker-list" role="listbox" aria-label="标签"></ul>
<p class="tp-foot dialog-meta"></p>
</form>
</dialog>
<dialog id="tagManageDialog" class="wide" aria-labelledby="tagManageTitle">
<form method="dialog">
<h2 id="tagManageTitle"></h2>
<p id="tagManageHint" class="dialog-hint"></p>
<div id="tagsRows" class="tag-rows"></div>
<div class="tag-add">
<input id="newTagInput" type="text" autocomplete="off" />
<button id="addTagBtn" type="button"></button>
<div class="dlg-body">
<p id="tagManageHint" class="dialog-hint"></p>
<!-- 标签管理 (.tm): the tags on the left, the picked one's details in #tmDetail. 分组管理: one list. -->
<div class="tm-cols">
<div class="tm-list">
<div id="tagsRows" class="tag-rows"></div>
<div class="tag-add">
<input id="newTagInput" type="text" autocomplete="off" />
<button id="addTagBtn" type="button"></button>
</div>
<p id="tmWhy" class="tm-why"></p>
</div>
<div id="tmDetail" class="tm-detail"></div>
</div>
</div>
<div class="dialog-actions">
<span id="tmMeta" class="dialog-meta"></span>
<span class="spacer"></span>
<button type="submit" class="primary">完成</button>
</div>
<div class="dialog-actions"><span class="spacer"></span><button type="submit" class="primary">完成</button></div>
</form>
</dialog>
<dialog id="aiTagDialog" class="wide" aria-labelledby="aiTagTitle"></dialog>
<dialog id="aiTagDialog" aria-labelledby="aiTagTitle"></dialog>
<!-- The 分拣台's confirm dialog (UI.askConfirm), as in triage/triage.html: 删除标签, U 撤销 and deleting AI 对话 ask here. -->
<dialog id="confirmDialog" aria-label="确认">
<form method="dialog">
Expand All @@ -67,28 +81,41 @@ <h2 id="confirmTitle"></h2>
</dialog>
<dialog id="helpDialog" aria-labelledby="helpTitle">
<form method="dialog">
<div class="dlg-body">
<div class="stack">
<h2 id="helpTitle" data-text="shortcuts">快捷键</h2>
<h3 data-text="keysMove">移动和选中</h3>
<dl class="keys">
<dt><kbd>J</kbd><kbd>↓</kbd> / <kbd>K</kbd><kbd>↑</kbd></dt><dd>移到下一张 / 上一张卡片</dd>
<dt><kbd>X</kbd></dt><dd>选中或取消选中当前卡片,和点卡片一样。Shift 点选中一段</dd>
<dt><kbd>J</kbd><kbd>↓</kbd></dt><dd>移到下一张卡片</dd>
<dt><kbd>K</kbd><kbd>↑</kbd></dt><dd data-text="keyPrevCard">上一张卡片</dd>
<dt><kbd>X</kbd></dt><dd>选中 / 取消选中当前卡片,和点卡片一样<small>Shift 点选中一段</small></dd>
<dt><kbd>Esc</kbd></dt><dd>清空选中</dd>
<dt><kbd>T</kbd></dt><dd>给当前卡片打标签</dd>
</dl>
<h3 data-text="keysCard">当前卡片</h3>
<dl class="keys">
<dt><kbd>T</kbd></dt><dd data-text="keyTag">打标签</dd>
<dt><kbd>1</kbd>–<kbd>9</kbd><kbd>0</kbd></dt><dd data-text="keyTagNumber">打标签时勾选或去掉第几个标签</dd>
<dt><kbd>Q</kbd></dt><dd>继续问</dd>
<dt><kbd>O</kbd><kbd>Enter</kbd></dt><dd>打开当前卡片的视频或网页</dd>
<dt><kbd>O</kbd><kbd>Enter</kbd></dt><dd>打开视频或网页</dd>
</dl>
<h3>整页</h3>
<dl class="keys">
<dt><kbd>I</kbd></dt><dd data-text="aiTag">AI 打标签</dd>
<dt><kbd>U</kbd></dt><dd>撤销上一步改标签</dd>
<dt><kbd>/</kbd></dt><dd data-text="keySearch">搜索(Esc 清空)</dd>
<dt><kbd>?</kbd></dt><dd data-text="keyHelp">显示本帮助</dd>
</dl>
</div>
</div>
<div class="dialog-actions"><span class="spacer"></span><button type="submit" class="primary" data-text="gotIt">知道了</button></div>
</form>
</dialog>
<!-- As 关注设置's AI 打标签 groups (triage.html); UI.fillSetRows writes the rows' names, hints and ranges. -->
<dialog id="readingSettingsDialog" aria-label="摘读记录设置">
<dialog id="readingSettingsDialog" class="set-single" aria-label="摘读记录设置">
<form method="dialog">
<h2>摘读记录设置</h2>
<div class="settings-ai">
<div class="dlg-body">
<div class="set-stack">
<section class="set-group">
<h3>标签</h3>
<div class="set-card">
Expand All @@ -105,6 +132,7 @@ <h3 data-text="aiParams">请求和 AI 参数</h3>
</div>
</section>
</div>
</div>
<div class="dialog-actions">
<button type="button" class="link" data-open-options aria-label="打开设置页" data-text="openSettings">打开设置页</button>
<span class="spacer"></span>
Expand Down
19 changes: 12 additions & 7 deletions extension/history/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function aiProviderId() {
}
const RECENT_CHECK = "在记录上逐个看,不对的按 T 或点「+ 标签」改";
// A batch's line (「AI 正在处理第 1 批…」, a wait) does not start with 正在 but is still in progress.
const aiProgress = (text) => (TagDialogs.ai.progress(aiTags, text), setStatus(text, false, null, true));
const aiProgress = (text, fail) => (TagDialogs.ai.progress(aiTags, text, "", fail && aiRemedy(fail)), setStatus(text, false, null, true));
const aiTags = {
who: "记录",
sees: `标题、是视频还是网页、现有标签和你与 AI 的对话(问和答,每条记录最多 ${UI.READING_AI_CHARS} 字);没有对话的记录看分拣台的 AI 总结和备注`,
Expand Down Expand Up @@ -434,16 +434,16 @@ function renderHead(all, groups) {
els.searchCount.textContent = UI.resultCount(els.search.value.trim() || filtered, groups.length);
const shown = shownPicks(groups);
els.selectAllSlot.innerHTML = UI.selectAllBox('data-f="select-all"', groups.length, shown.length, "这里没有列出记录");
// The bar's buttons act on the listed selected records and say how many; when the search and filters hide every
// selected one they count all of them, off with selbar's none, as on the 分拣台.
// The bar says how many are selected once, so its buttons carry no count (as 收藏夹's); when the search and filters
// hide every selected one they are off with selbar's none, as on the 分拣台.
const n = shown.length || selected.size;
// 删除 removes AI conversations only, so its N counts the selected records that have one and says when that is fewer.
// 删除 removes AI conversations only: its tooltip says when fewer of the selected records have one.
// A YouTube video's 备注 is not on the 分拣台 (B站 收藏夹 only), so the reason names no other place.
const del = deletableKeys(shown.length ? shown : [...selected]).length;
const acts = (none) =>
UI.actBtn('data-sel="md"', n > 1 ? `打包下载选中的 ${n} 个 .md` : "下载选中的 1 个 .md", { reason: none }) +
UI.actBtn('data-sel="md"', n > 1 ? "打包下载 .md" : MdgErrors.LABEL.downloadMd, { reason: none }) +
UI.actBtn('data-sel="tags"', MdgErrors.LABEL.tagsMenu, { reason: none }) +
UI.actBtn('data-sel="delete"', del ? `删除选中的 ${del} 个的 AI 对话` : "删除选中的 AI 对话", { cls: "danger", reason: none || (del ? "" : "选中的记录没有 AI 对话"), title: del < n ? `选中的 ${n} 个里,${n - del} 个没有 AI 对话,删除后会留下` : "" });
UI.actBtn('data-sel="delete"', "删除 AI 对话", { cls: "danger", reason: none || (del ? "" : "选中的记录没有 AI 对话"), title: del < n ? `选中的 ${n} 个里,${n - del} 个没有 AI 对话,删除后会留下` : "" });
els.selbar.innerHTML = selected.size ? UI.selbar({ label: "选中的记录", n: shown.length, hidden: selected.size - shown.length, clearAttrs: 'data-sel="clear"', acts }) : "";
setReason(els.clearAll, !conversations.length ? "还没有 AI 对话" : conversations.every(isStarredConv) ? "只剩加了星标的记录的 AI 对话" : "");
if (focused) [...els.filters.querySelectorAll("[data-f]")].find((b) => b.dataset.f === focused)?.focus();
Expand Down Expand Up @@ -730,7 +730,12 @@ async function removeConversations(keep, done, unselect = []) {

async function deleteGroups(keys) {
keys = deletableKeys(keys);
if (!keys.length || !(await UI.askConfirm(`删除 ${keys.length} 条记录的全部 AI 对话?`, "删除后不能恢复。", "删除", { danger: true }))) return;
if (!keys.length) return;
// The body names what goes: one record's title and how many conversations, or the titles as a batch confirm lists them.
const groups = groupByVideo(conversations).filter((g) => keys.includes(g.key));
const name = (g) => (g.title === g.context.videoId ? MdgErrors.TEXT.untitledVideo : g.title);
const what = groups.length === 1 ? `<p>「${esc(name(groups[0]))}」 · ${groups[0].convs.length} 段对话</p>` : UI.confirmList(groups.map(name));
if (!(await UI.askConfirm(`删除 ${keys.length} 条记录的全部 AI 对话?`, `${what}<p class="lead">删除后不能恢复。</p>`, "删除", { danger: true }))) return;
await removeConversations((c) => !keys.includes(c?.contextKey || c?.id), `已删除 ${keys.length} 条记录的 AI 对话`, keys);
}

Expand Down
Loading
Loading