diff --git a/docs/README.md b/docs/README.md
index 999324d..9f9c359 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -57,6 +57,7 @@ Contributing? See the [contributor guide](../CONTRIBUTING.md) and its ecosystem
- **Text notes** — capture a plain-text or Markdown note with a title and no URL; the byte-preserving note is stored as a normal deduplicated blob and opens in the usual entry-rail preview
- **In-progress capture indicator** — running captures appear as a compact spinner row in the entries list until they finish, replacing the earlier grey skeleton block
- **Dark mode** — toggle light/dark from the topbar or auth screen, or configure System/Light/Dark under **Settings › Profile**
+- **Cookie rules** — global, wildcard, or regex rules under **Settings › Cookies** inject custom cookies into capture network requests (yt-dlp, HTTP downloads, web snapshots). The input accepts native JSON, browser extension exports (Cookie-Editor, EditThisCookie), Netscape `cookies.txt`, or `Cookie:` header strings with automatic formatting and collision-safe merge on paste
## Quick Start
diff --git a/frontend/src/components/SettingsView.jsx b/frontend/src/components/SettingsView.jsx
index 991349e..f70b585 100644
--- a/frontend/src/components/SettingsView.jsx
+++ b/frontend/src/components/SettingsView.jsx
@@ -12,6 +12,7 @@ import {
} from '../api.js'
import { describeExpiry, formatTimestamp } from '../utils.js'
import { useTheme } from '../useTheme.js'
+import { normalizeCookiesInput, pasteCookies } from '../cookieImport.js'
const ROLE_ADMIN = 4
const ROLE_OWNER = 8
@@ -683,9 +684,9 @@ function CookiesTab() {
async function handleAdd(e) {
e.preventDefault()
- // Validate JSON
- try { JSON.parse(cookiesInput) } catch {
- setAddMsg({ ok: false, text: 'cookies must be valid JSON, e.g. {"session": "abc"}' })
+ const normalized = normalizeCookiesInput(cookiesInput)
+ if (!normalized.ok) {
+ setAddMsg({ ok: false, text: normalized.error })
return
}
setAdding(true); setAddMsg(null)
@@ -693,7 +694,7 @@ function CookiesTab() {
await createCookieRule(
patternKind === 'global' ? null : urlPattern.trim(),
patternKind,
- cookiesInput,
+ normalized.json,
)
setUrlPattern('')
setCookiesInput('{}')
@@ -707,6 +708,44 @@ function CookiesTab() {
}
}
+ function handlePasteAdd(e) {
+ const clip = e.clipboardData?.getData('text')
+ if (!clip) return
+ const start = e.target.selectionStart ?? 0
+ const end = e.target.selectionEnd ?? 0
+ const action = pasteCookies(cookiesInput, start, end, clip)
+ if (!action) return
+ e.preventDefault()
+ if (action.error) {
+ setAddMsg({ ok: false, text: action.error })
+ } else {
+ setCookiesInput(action.text)
+ setAddMsg({ ok: true, text: action.message })
+ }
+ }
+
+ function handlePasteEdit(ruleUid, e) {
+ const clip = e.clipboardData?.getData('text')
+ if (!clip) return
+ const current = edits[ruleUid]?.cookiesInput ?? ''
+ const start = e.target.selectionStart ?? 0
+ const end = e.target.selectionEnd ?? 0
+ const action = pasteCookies(current, start, end, clip)
+ if (!action) return
+ e.preventDefault()
+ if (action.error) {
+ setEdits(prev => ({
+ ...prev,
+ [ruleUid]: { ...prev[ruleUid], msg: { ok: false, text: action.error } },
+ }))
+ } else {
+ setEdits(prev => ({
+ ...prev,
+ [ruleUid]: { ...prev[ruleUid], cookiesInput: action.text, msg: { ok: true, text: action.message } },
+ }))
+ }
+ }
+
async function handleDelete(ruleUid) {
try {
await deleteCookieRule(ruleUid)
@@ -733,13 +772,14 @@ function CookiesTab() {
async function saveEdit(rule) {
const edit = edits[rule.rule_uid]
- try { JSON.parse(edit.cookiesInput) } catch {
- setEdits(prev => ({ ...prev, [rule.rule_uid]: { ...prev[rule.rule_uid], msg: { ok: false, text: 'Invalid JSON' } } }))
+ const normalized = normalizeCookiesInput(edit.cookiesInput)
+ if (!normalized.ok) {
+ setEdits(prev => ({ ...prev, [rule.rule_uid]: { ...prev[rule.rule_uid], msg: { ok: false, text: normalized.error } } }))
return
}
setEdits(prev => ({ ...prev, [rule.rule_uid]: { ...prev[rule.rule_uid], saving: true, msg: null } }))
try {
- await updateCookieRule(rule.rule_uid, { cookies_json: edit.cookiesInput })
+ await updateCookieRule(rule.rule_uid, { cookies_json: normalized.json })
cancelEdit(rule.rule_uid)
await load()
} catch (err) {
@@ -785,6 +825,7 @@ function CookiesTab() {
style={{ fontFamily: 'monospace', fontSize: 12, width: '100%', minHeight: 60 }}
value={edit.cookiesInput}
onChange={ev => setEdits(prev => ({ ...prev, [rule.rule_uid]: { ...prev[rule.rule_uid], cookiesInput: ev.target.value } }))}
+ onPaste={ev => handlePasteEdit(rule.rule_uid, ev)}
/>
{edit.msg &&
{edit.msg.text}
}
@@ -847,9 +888,13 @@ function CookiesTab() {
style={{ fontFamily: 'monospace', fontSize: 13, minHeight: 70 }}
value={cookiesInput}
onChange={e => setCookiesInput(e.target.value)}
+ onPaste={handlePasteAdd}
placeholder='{"SESSION": "abc123", "token": "xyz"}'
required
/>
+
+ Paste JSON object, extension export, Netscape cookies.txt, or header string.
+
{addMsg && {addMsg.text}
}