Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(cookies): add per-domain toggle and extension auto-sync setting

IGECTa273faca0417
diff --git a/browser-extension/chrome/pages/options.html b/browser-extension/chrome/pages/options.html
index 510a2650..884caa34 100644
--- a/browser-extension/chrome/pages/options.html
+++ b/browser-extension/chrome/pages/options.html
@@ -67,6 +67,13 @@
</label>
</details>
+ <label class="field">
+ <span class="label">
+ <input id="auto-capture-cookies" type="checkbox" checked />
+ Automatically sync browser cookies to OmniGet
+ </span>
+ </label>
+
<div class="actions">
<button id="pair-now" type="button" class="button primary">Pair now</button>
<button id="save" type="submit" class="button">Save</button>
diff --git a/browser-extension/chrome/pages/options.js b/browser-extension/chrome/pages/options.js
index 3b675b2d..fcace3dd 100644
--- a/browser-extension/chrome/pages/options.js
+++ b/browser-extension/chrome/pages/options.js
@@ -1,6 +1,8 @@
import {
loadBridgeConfig,
saveBridgeConfig,
+ loadAutoCaptureCookies,
+ saveAutoCaptureCookies,
checkBridgeHealth,
discoverBridgeEndpoint,
trimEndpoint,
@@ -234,6 +236,7 @@ if (typeof document !== "undefined") {
const discoveryMessage = document.getElementById("discovery-message");
const endpointHint = document.getElementById("endpoint-hint");
const advancedDetails = document.getElementById("advanced");
+ const autoCaptureCookiesInput = document.getElementById("auto-capture-cookies");
const FALLBACK_ENDPOINT = "http://127.0.0.1:47720";
@@ -332,6 +335,9 @@ if (typeof document !== "undefined") {
endpointInput.value = endpoint || "";
tokenInput.value = token || "";
+ if (autoCaptureCookiesInput) {
+ autoCaptureCookiesInput.checked = await loadAutoCaptureCookies();
+ }
// Skip auto-discovery if the user is already paired AND we have a stored
// endpoint that responds — they're probably here to change the token, no
@@ -378,6 +384,18 @@ if (typeof document !== "undefined") {
revealBtn.setAttribute("aria-pressed", String(next !== "password"));
});
+ if (autoCaptureCookiesInput) {
+ autoCaptureCookiesInput.addEventListener("change", async () => {
+ await saveAutoCaptureCookies(autoCaptureCookiesInput.checked);
+ setStatus(
+ autoCaptureCookiesInput.checked
+ ? "Automatic cookie sync enabled."
+ : "Automatic cookie sync disabled.",
+ "ok"
+ );
+ });
+ }
+
form.addEventListener("submit", async (event) => {
event.preventDefault();
const endpoint = resolvedEndpoint();
diff --git a/browser-extension/chrome/src/background.js b/browser-extension/chrome/src/background.js
index 2f807e27..a4d386a0 100644
--- a/browser-extension/chrome/src/background.js
+++ b/browser-extension/chrome/src/background.js
@@ -20,6 +20,7 @@ import {
sendCookiesViaBridge,
autoPair,
loadBridgeConfig,
+ loadAutoCaptureCookies,
AUTOPAIR_ALARM_NAME,
STORAGE_KEY_TOKEN,
} from "./bridge-client.js";
@@ -626,6 +627,10 @@ function debounceCookieCapture(platform) {
}
async function capturePlatformCookies(platform, force = false) {
+ if (!(await loadAutoCaptureCookies())) {
+ console.debug("[OmniGet] cookie auto-capture disabled", platform);
+ return { ok: false, reason: "disabled" };
+ }
const lastSent = cookieLastSentAt.get(platform) || 0;
if (!force && Date.now() - lastSent < COOKIE_AUTO_CAPTURE_MIN_INTERVAL_MS) {
console.debug("[OmniGet] cookie capture throttled", platform);
diff --git a/browser-extension/chrome/src/bridge-client.js b/browser-extension/chrome/src/bridge-client.js
index b9f21824..0e4b8ff1 100644
--- a/browser-extension/chrome/src/bridge-client.js
+++ b/browser-extension/chrome/src/bridge-client.js
@@ -15,6 +15,7 @@
export const STORAGE_KEY_ENDPOINT = "bridge_endpoint";
export const STORAGE_KEY_TOKEN = "bridge_token";
+export const STORAGE_KEY_AUTO_CAPTURE_COOKIES = "auto_capture_cookies";
// Name of the low-frequency autopair alarm owned by background.js. Exported
// so the 401 recovery path below can re-arm it without duplicating the name.
export const AUTOPAIR_ALARM_NAME = "omniget-autopair";
@@ -67,6 +68,25 @@ export async function saveBridgeConfig(
});
}
+export async function loadAutoCaptureCookies({ storage = globalThis.chrome?.storage?.local } = {}) {
+ if (!storage?.get) return true;
+ return new Promise((resolve) => {
+ storage.get([STORAGE_KEY_AUTO_CAPTURE_COOKIES], (items) => {
+ resolve(items?.[STORAGE_KEY_AUTO_CAPTURE_COOKIES] !== false);
+ });
+ });
+}
+
+export async function saveAutoCaptureCookies(
+ enabled,
+ { storage = globalThis.chrome?.storage?.local } = {}
+) {
+ if (!storage?.set) return false;
+ return new Promise((resolve) => {
+ storage.set({ [STORAGE_KEY_AUTO_CAPTURE_COOKIES]: Boolean(enabled) }, () => resolve(true));
+ });
+}
+
// Forget the stored token (keep the endpoint — it's still valid). Used when
// the desktop app rejects our bearer, e.g. after the user rotated the token
// in Settings; keeping the stale token around would leave this browser
diff --git a/browser-extension/chrome/tests/bridge-client.test.mjs b/browser-extension/chrome/tests/bridge-client.test.mjs
index 50befca3..9597b7a4 100644
--- a/browser-extension/chrome/tests/bridge-client.test.mjs
+++ b/browser-extension/chrome/tests/bridge-client.test.mjs
@@ -5,11 +5,14 @@ import {
trimEndpoint,
loadBridgeConfig,
saveBridgeConfig,
+ loadAutoCaptureCookies,
+ saveAutoCaptureCookies,
checkBridgeHealth,
discoverBridgeEndpoint,
sendViaBridge,
STORAGE_KEY_ENDPOINT,
STORAGE_KEY_TOKEN,
+ STORAGE_KEY_AUTO_CAPTURE_COOKIES,
DEFAULT_PORT_RANGE,
} from "../src/bridge-client.js";
@@ -231,3 +234,14 @@ test("sendViaBridge bubbles up app-level error code on a 4xx response", async ()
assert.equal(result.code, "INVALID_URL");
assert.equal(result.message, "bad URL");
});
+
+test("loadAutoCaptureCookies defaults to true and saveAutoCaptureCookies persists false", async () => {
+ const storage = fakeStorage();
+ assert.equal(await loadAutoCaptureCookies({ storage }), true);
+ await saveAutoCaptureCookies(false, { storage });
+ assert.equal(storage.data[STORAGE_KEY_AUTO_CAPTURE_COOKIES], false);
+ assert.equal(await loadAutoCaptureCookies({ storage }), false);
+ await saveAutoCaptureCookies(true, { storage });
+ assert.equal(await loadAutoCaptureCookies({ storage }), true);
+});
+
diff --git a/browser-extension/firefox/pages/options.html b/browser-extension/firefox/pages/options.html
index 510a2650..884caa34 100644
--- a/browser-extension/firefox/pages/options.html
+++ b/browser-extension/firefox/pages/options.html
@@ -67,6 +67,13 @@
</label>
</details>
+ <label class="field">
+ <span class="label">
+ <input id="auto-capture-cookies" type="checkbox" checked />
+ Automatically sync browser cookies to OmniGet
+ </span>
+ </label>
+
<div class="actions">
<button id="pair-now" type="button" class="button primary">Pair now</button>
<button id="save" type="submit" class="button">Save</button>
diff --git a/browser-extension/firefox/pages/options.js b/browser-extension/firefox/pages/options.js
index 3b675b2d..fcace3dd 100644
--- a/browser-extension/firefox/pages/options.js
+++ b/browser-extension/firefox/pages/options.js
@@ -1,6 +1,8 @@
import {
loadBridgeConfig,
saveBridgeConfig,
+ loadAutoCaptureCookies,
+ saveAutoCaptureCookies,
checkBridgeHealth,
discoverBridgeEndpoint,
trimEndpoint,
@@ -234,6 +236,7 @@ if (typeof document !== "undefined") {
const discoveryMessage = document.getElementById("discovery-message");
const endpointHint = document.getElementById("endpoint-hint");
const advancedDetails = document.getElementById("advanced");
+ const autoCaptureCookiesInput = document.getElementById("auto-capture-cookies");
const FALLBACK_ENDPOINT = "http://127.0.0.1:47720";
@@ -332,6 +335,9 @@ if (typeof document !== "undefined") {
endpointInput.value = endpoint || "";
tokenInput.value = token || "";
+ if (autoCaptureCookiesInput) {
+ autoCaptureCookiesInput.checked = await loadAutoCaptureCookies();
+ }
// Skip auto-discovery if the user is already paired AND we have a stored
// endpoint that responds — they're probably here to change the token, no
@@ -378,6 +384,18 @@ if (typeof document !== "undefined") {
revealBtn.setAttribute("aria-pressed", String(next !== "password"));
});
+ if (autoCaptureCookiesInput) {
+ autoCaptureCookiesInput.addEventListener("change", async () => {
+ await saveAutoCaptureCookies(autoCaptureCookiesInput.checked);
+ setStatus(
+ autoCaptureCookiesInput.checked
+ ? "Automatic cookie sync enabled."
+ : "Automatic cookie sync disabled.",
+ "ok"
+ );
+ });
+ }
+
form.addEventListener("submit", async (event) => {
event.preventDefault();
const endpoint = resolvedEndpoint();
diff --git a/browser-extension/firefox/src/background.js b/browser-extension/firefox/src/background.js
index 2f807e27..a4d386a0 100644
--- a/browser-extension/firefox/src/background.js
+++ b/browser-extension/firefox/src/background.js
@@ -20,6 +20,7 @@ import {
sendCookiesViaBridge,
autoPair,
loadBridgeConfig,
+ loadAutoCaptureCookies,
AUTOPAIR_ALARM_NAME,
STORAGE_KEY_TOKEN,
} from "./bridge-client.js";
@@ -626,6 +627,10 @@ function debounceCookieCapture(platform) {
}
async function capturePlatformCookies(platform, force = false) {
+ if (!(await loadAutoCaptureCookies())) {
+ console.debug("[OmniGet] cookie auto-capture disabled", platform);
+ return { ok: false, reason: "disabled" };
+ }
const lastSent = cookieLastSentAt.get(platform) || 0;
if (!force && Date.now() - lastSent < COOKIE_AUTO_CAPTURE_MIN_INTERVAL_MS) {
console.debug("[OmniGet] cookie capture throttled", platform);
diff --git a/browser-extension/firefox/src/bridge-client.js b/browser-extension/firefox/src/bridge-client.js
index b9f21824..0e4b8ff1 100644
--- a/browser-extension/firefox/src/bridge-client.js
+++ b/browser-extension/firefox/src/bridge-client.js
@@ -15,6 +15,7 @@
export const STORAGE_KEY_ENDPOINT = "bridge_endpoint";
export const STORAGE_KEY_TOKEN = "bridge_token";
+export const STORAGE_KEY_AUTO_CAPTURE_COOKIES = "auto_capture_cookies";
// Name of the low-frequency autopair alarm owned by background.js. Exported
// so the 401 recovery path below can re-arm it without duplicating the name.
export const AUTOPAIR_ALARM_NAME = "omniget-autopair";
@@ -67,6 +68,25 @@ export async function saveBridgeConfig(
});
}
+export async function loadAutoCaptureCookies({ storage = globalThis.chrome?.storage?.local } = {}) {
+ if (!storage?.get) return true;
+ return new Promise((resolve) => {
+ storage.get([STORAGE_KEY_AUTO_CAPTURE_COOKIES], (items) => {
+ resolve(items?.[STORAGE_KEY_AUTO_CAPTURE_COOKIES] !== false);
+ });
+ });
+}
+
+export async function saveAutoCaptureCookies(
+ enabled,
+ { storage = globalThis.chrome?.storage?.local } = {}
+) {
+ if (!storage?.set) return false;
+ return new Promise((resolve) => {
+ storage.set({ [STORAGE_KEY_AUTO_CAPTURE_COOKIES]: Boolean(enabled) }, () => resolve(true));
+ });
+}
+
// Forget the stored token (keep the endpoint — it's still valid). Used when
// the desktop app rejects our bearer, e.g. after the user rotated the token
// in Settings; keeping the stale token around would leave this browser
diff --git a/src-tauri/src/cookies/commands.rs b/src-tauri/src/cookies/commands.rs
index 5b73eb92..72e35a18 100644
--- a/src-tauri/src/cookies/commands.rs
+++ b/src-tauri/src/cookies/commands.rs
@@ -225,6 +225,20 @@ pub async fn cookies_read_as_json(
.collect())
}
+#[derive(Debug, Deserialize)]
+pub struct SetBucketEnabledRequest {
+ pub domain: String,
+ pub enabled: bool,
+}
+
+#[tauri::command]
+pub async fn cookies_set_bucket_enabled(
+ request: SetBucketEnabledRequest,
+) -> Result<OkResponse, String> {
+ storage::set_bucket_enabled(&request.domain, request.enabled).map_err(|e| e.to_string())?;
+ Ok(OkResponse { ok: true })
+}
+
#[tauri::command]
pub async fn cookies_accounts_for_url(url: String) -> Result<AccountsForUrlResponse, String> {
let parsed = url::Url::parse(&url).map_err(|e| e.to_string())?;
@@ -237,6 +251,12 @@ pub async fn cookies_accounts_for_url(url: String) -> Result<AccountsForUrlRespo
});
}
let registry = storage::load_registry();
+ if !storage::is_domain_enabled(&registry, &root) {
+ return Ok(AccountsForUrlResponse {
+ domain: root,
+ accounts: Vec::new(),
+ });
+ }
let accounts = registry
.buckets
.get(&root)
diff --git a/src-tauri/src/cookies/storage.rs b/src-tauri/src/cookies/storage.rs
index b1052d54..cd3884b5 100644
--- a/src-tauri/src/cookies/storage.rs
+++ b/src-tauri/src/cookies/storage.rs
@@ -13,7 +13,7 @@
//! The format inside each file is Netscape — same as the legacy
//! `chrome-extension-cookies.txt` so yt-dlp consumes it unchanged.
-use std::collections::BTreeMap;
+use std::collections::{BTreeMap, BTreeSet};
use std::fs;
use std::path::{Path, PathBuf};
@@ -25,6 +25,10 @@ use crate::extension_storage::ExtensionCookie;
const META_FILE: &str = "_meta.json";
const DEFAULT_SLUG: &str = "_default";
+fn default_true() -> bool {
+ true
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountEntry {
pub slug: String,
@@ -39,16 +43,30 @@ pub struct AccountEntry {
pub last_used_at_ms: Option<i64>,
}
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BucketEntry {
pub platform_kind: String,
pub accounts: Vec<AccountEntry>,
+ #[serde(default = "default_true")]
+ pub enabled: bool,
+}
+
+impl Default for BucketEntry {
+ fn default() -> Self {
+ Self {
+ platform_kind: String::new(),
+ accounts: Vec::new(),
+ enabled: true,
+ }
+ }
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CookieRegistry {
#[serde(default)]
pub buckets: BTreeMap<String, BucketEntry>,
+ #[serde(default)]
+ pub disabled_domains: BTreeSet<String>,
}
pub fn cookies_root() -> PathBuf {
@@ -230,6 +248,96 @@ pub fn write_account_file(
Ok(cookies.len())
}
+pub(crate) fn upsert_bucket_account_in_registry(
+ registry: &mut CookieRegistry,
+ root: &str,
+ slug: &str,
+ count: usize,
+ now: i64,
+ source: &IngestSource,
+) {
+ let platform = PlatformKind::from_domain(root);
+ let source_url = normalize_source_url(source.source_url.as_deref(), root);
+ let is_disabled = registry.disabled_domains.contains(root);
+ let bucket = registry
+ .buckets
+ .entry(root.to_string())
+ .or_insert_with(|| BucketEntry {
+ platform_kind: platform.as_str().to_string(),
+ accounts: Vec::new(),
+ enabled: !is_disabled,
+ });
+ bucket.platform_kind = platform.as_str().to_string();
+ if is_disabled {
+ bucket.enabled = false;
+ }
+
+ let alias_default = format!("{} · {}", platform_display(platform), human_date(now),);
+ let new_alias = source.alias_hint.clone().unwrap_or(alias_default);
+
+ if let Some(existing) = bucket.accounts.iter_mut().find(|a| a.slug == slug) {
+ existing.captured_at_ms = now;
+ existing.cookie_count = count;
+ if let Some(ref u) = source_url {
+ existing.source_url = Some(u.clone());
+ }
+ existing.source_label = Some(source.source_label.clone());
+ if source.alias_hint.is_some() {
+ existing.alias = new_alias;
+ }
+ } else {
+ bucket.accounts.push(AccountEntry {
+ slug: slug.to_string(),
+ alias: new_alias,
+ source_url,
+ source_label: Some(source.source_label.clone()),
+ captured_at_ms: now,
+ cookie_count: count,
+ last_used_at_ms: None,
+ });
+ }
+}
+
+fn normalize_domain_key(domain: &str) -> String {
+ let r = root_domain_of(domain);
+ if r.is_empty() {
+ domain.trim_start_matches('.').to_lowercase()
+ } else {
+ r
+ }
+}
+
+pub fn is_domain_enabled(registry: &CookieRegistry, domain: &str) -> bool {
+ let root = normalize_domain_key(domain);
+ if registry.disabled_domains.contains(&root) {
+ return false;
+ }
+ registry
+ .buckets
+ .get(&root)
+ .map(|b| b.enabled)
+ .unwrap_or(true)
+}
+
+pub fn apply_bucket_enabled(registry: &mut CookieRegistry, domain: &str, enabled: bool) {
+ let root = normalize_domain_key(domain);
+ if enabled {
+ registry.disabled_domains.remove(&root);
+ } else {
+ registry.disabled_domains.insert(root.clone());
+ }
+ if let Some(bucket) = registry.buckets.get_mut(&root) {
+ bucket.enabled = enabled;
+ }
+}
+
+pub fn set_bucket_enabled(domain: &str, enabled: bool) -> anyhow::Result<()> {
+ let mut registry = load_registry();
+ apply_bucket_enabled(&mut registry, domain, enabled);
+ save_registry(&registry)?;
+ Ok(())
+}
+
pub fn ingest_batch(
cookies: &[ExtensionCookie],
source: IngestSource,
@@ -249,42 +357,7 @@ pub fn ingest_batch(
for (root, group) in by_root.iter() {
let count = write_account_file(root, DEFAULT_SLUG, group)?;
- let platform = PlatformKind::from_domain(root);
- let source_url = normalize_source_url(source.source_url.as_deref(), root);
- let bucket = registry
- .buckets
- .entry(root.clone())
- .or_insert_with(|| BucketEntry {
- platform_kind: platform.as_str().to_string(),
- accounts: Vec::new(),
- });
- bucket.platform_kind = platform.as_str().to_string();
-
- let alias_default = format!("{} · {}", platform_display(platform), human_date(now),);
- let new_alias = source.alias_hint.clone().unwrap_or(alias_default);
-
- if let Some(existing) = bucket.accounts.iter_mut().find(|a| a.slug == DEFAULT_SLUG) {
- existing.captured_at_ms = now;
- existing.cookie_count = count;
- if let Some(ref u) = source_url {
- existing.source_url = Some(u.clone());
- }
- existing.source_label = Some(source.source_label.clone());
- if source.alias_hint.is_some() {
- existing.alias = new_alias;
- }
- } else {
- bucket.accounts.push(AccountEntry {
- slug: DEFAULT_SLUG.to_string(),
- alias: new_alias,
- source_url,
- source_label: Some(source.source_label.clone()),
- captured_at_ms: now,
- cookie_count: count,
- last_used_at_ms: None,
- });
- }
-
+ upsert_bucket_account_in_registry(&mut registry, root, DEFAULT_SLUG, count, now, &source);
written.push((root.clone(), count));
}
@@ -410,13 +483,11 @@ pub fn ingest_to_account(
}
let mut registry = load_registry();
- let bucket = registry.buckets.entry(root.clone()).or_insert_with(|| {
- let platform = PlatformKind::from_domain(&root);
- BucketEntry {
- platform_kind: platform.as_str().to_string(),
- accounts: Vec::new(),
- }
- });
+ let existing_slugs: BTreeSet<String> = registry
+ .buckets
+ .get(&root)
+ .map(|b| b.accounts.iter().map(|a| a.slug.clone()).collect())
+ .unwrap_or_default();
let mut slug = if requested_slug.trim().is_empty() {
slugify_alias(source.alias_hint.as_deref().unwrap_or(""))
@@ -428,7 +499,7 @@ pub fn ingest_to_account(
}
let mut candidate = slug.clone();
let mut suffix = 2;
- while bucket.accounts.iter().any(|a| a.slug == candidate) {
+ while existing_slugs.contains(&candidate) {
candidate = format!("{}-{}", slug, suffix);
suffix += 1;
}
@@ -436,24 +507,7 @@ pub fn ingest_to_account(
let count = write_account_file(&root, &final_slug, &scoped)?;
let now = current_unix_ms();
- let source_url = normalize_source_url(source.source_url.as_deref(), &root);
- let alias = source.alias_hint.clone().unwrap_or_else(|| {
- format!(
- "{} · {}",
- platform_display(PlatformKind::from_domain(&root)),
- human_date(now)
- )
- });
-
- bucket.accounts.push(AccountEntry {
- slug: final_slug.clone(),
- alias,
- source_url,
- source_label: Some(source.source_label.clone()),
- captured_at_ms: now,
- cookie_count: count,
- last_used_at_ms: None,
- });
+ upsert_bucket_account_in_registry(&mut registry, &root, &final_slug, count, now, &source);
save_registry(&registry)?;
Ok((final_slug, count))
@@ -476,6 +530,10 @@ pub fn rename_account(domain: &str, slug: &str, new_alias: &str) -> anyhow::Resu
}
pub fn account_path_for_consumer(domain: &str, slug: Option<&str>) -> Option<PathBuf> {
+ let registry = load_registry();
+ if !is_domain_enabled(&registry, domain) {
+ return None;
+ }
let slug = slug.unwrap_or(DEFAULT_SLUG);
let path = account_file(domain, slug);
if path.exists() {
@@ -600,4 +658,36 @@ mod tests {
Some("https://youtube.com/".to_string())
);
}
+
+ #[test]
+ fn disabled_bucket_blocks_consumer_and_survives_reingest() {
+ let mut reg = CookieRegistry::default();
+ assert!(is_domain_enabled(&reg, "youtube.com"));
+
+ apply_bucket_enabled(&mut reg, "youtube.com", false);
+ assert!(!is_domain_enabled(&reg, "youtube.com"));
+
+ // Simulate extension auto-capture upserting into registry for a disabled domain:
+ upsert_bucket_account_in_registry(
+ &mut reg,
+ "youtube.com",
+ DEFAULT_SLUG,
+ 5,
+ 1700000000000,
+ &IngestSource {
+ source_url: Some("https://www.youtube.com/".to_string()),
+ source_label: "Browser extension (auto-capture)".to_string(),
+ alias_hint: None,
+ },
+ );
+ assert!(
+ !is_domain_enabled(&reg, "youtube.com"),
+ "auto-capture re-ingest must not re-enable a disabled bucket"
+ );
+ assert_eq!(reg.buckets.get("youtube.com").unwrap().enabled, false);
+
+ apply_bucket_enabled(&mut reg, "youtube.com", true);
+ assert!(is_domain_enabled(&reg, "youtube.com"));
+ assert_eq!(reg.buckets.get("youtube.com").unwrap().enabled, true);
+ }
}
diff --git a/src/components/settings/SettingsCookies.svelte b/src/components/settings/SettingsCookies.svelte
index 72532f51..d5c9bfa6 100644
--- a/src/components/settings/SettingsCookies.svelte
+++ b/src/components/settings/SettingsCookies.svelte
@@ -21,7 +21,7 @@
cookie_count: number;
last_used_at_ms: number | null;
};
- type BucketEntry = { platform_kind: string; accounts: Account[] };
+ type BucketEntry = { platform_kind: string; enabled?: boolean; accounts: Account[] };
type Registry = { buckets: Record<string, BucketEntry> };
type ListResponse = { registry: Registry; cookies_dir: string };
type ImportResponse = {
@@ -259,6 +259,15 @@
}
}
+ async function handleToggleBucketEnabled(domain: string, enabled: boolean) {
+ try {
+ await invoke("cookies_set_bucket_enabled", { request: { domain, enabled } });
+ await reload();
+ } catch (e) {
+ showToast("error", String(e));
+ }
+ }
+
function askClear(domain: string, slug: string) {
confirmDomain = domain;
confirmSlug = slug;
@@ -582,6 +591,7 @@
onClear={askClear}
onAddAccount={openAddAccount}
onTest={handleTest}
+ onToggleEnabled={handleToggleBucketEnabled}
selected={selectedCookies}
onToggleSelection={toggleCookieSelection}
/>
diff --git a/src/lib/components/cookies/CookieBucketCard.svelte b/src/lib/components/cookies/CookieBucketCard.svelte
index 4301cd69..a1bc1a13 100644
--- a/src/lib/components/cookies/CookieBucketCard.svelte
+++ b/src/lib/components/cookies/CookieBucketCard.svelte
@@ -16,6 +16,7 @@
type Bucket = {
domain: string;
platform_kind: string;
+ enabled?: boolean;
accounts: Account[];
};
@@ -31,6 +32,7 @@
onClear: (domain: string, slug: string) => void;
onAddAccount?: (domain: string) => void;
onTest?: (domain: string, slug: string) => void;
+ onToggleEnabled?: (domain: string, enabled: boolean) => void;
selected?: Record<string, boolean>;
onToggleSelection?: (domain: string, slug: string, checked: boolean) => void;
};
@@ -45,9 +47,11 @@
onClear,
onAddAccount,
onTest,
+ onToggleEnabled,
selected = {},
onToggleSelection,
}: Props = $props();
+ let bucketEnabled = $derived(bucket.enabled !== false);
let primaryAccount = $derived(bucket.accounts.find((a) => a.slug === "_default") ?? bucket.accounts[0]);
let extraAccounts = $derived(bucket.accounts.filter((a) => a !== primaryAccount));
@@ -219,6 +223,7 @@
<article
class="bucket-card"
+ class:disabled-bucket={!bucketEnabled}
class:selectable={!!onToggleSelection && !!primaryAccount}
class:selected={!!primaryAccount && !!selected[keyFor(primaryAccount.slug)]}
data-status={status}
@@ -254,6 +259,16 @@
</svg>
</button>
{/if}
+ {#if onToggleEnabled}
+ <label class="bucket-enabled-toggle" title={bucketEnabled ? "Use cookies for this domain" : "Cookies disabled for this domain"}>
+ <input
+ type="checkbox"
+ checked={bucketEnabled}
+ onchange={(e) => onToggleEnabled?.(bucket.domain, e.currentTarget.checked)}
+ />
+ <span>{bucketEnabled ? "Enabled" : "Disabled"}</span>
+ </label>
+ {/if}
</div>
<p class="platform-line">
@@ -412,11 +427,30 @@
flex-direction: column;
gap: 4px;
}
+ .bucket-card.disabled-bucket {
+ opacity: 0.62;
+ }
.top-row {
display: flex;
align-items: center;
+ justify-content: space-between;
+ gap: 10px;
min-height: 24px;
}
+ .bucket-enabled-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 11px;
+ color: var(--tertiary);
+ cursor: pointer;
+ user-select: none;
+ flex-shrink: 0;
+ }
+ .bucket-enabled-toggle input {
+ accent-color: var(--accent);
+ cursor: pointer;
+ }
.alias-display {
display: inline-flex;
align-items: center;