From e293c36b979f4c1098438da570a8fcc7c63c5a59 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Thu, 16 Apr 2026 01:55:32 +0400 Subject: [PATCH] refactor: cleanup --- src-tauri/src/cookie_manager.rs | 35 ++++++++++++++++++++++++-------- src-tauri/src/sync/engine.rs | 13 +++++++++++- src-tauri/src/wayfern_manager.rs | 35 +++++++++++++++++++++++++++++++- src/components/ui/chart.tsx | 7 ++++++- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/cookie_manager.rs b/src-tauri/src/cookie_manager.rs index 426e4aa..a5cfa74 100644 --- a/src-tauri/src/cookie_manager.rs +++ b/src-tauri/src/cookie_manager.rs @@ -198,11 +198,20 @@ impl CookieManager { match profile.browser.as_str() { "wayfern" => { - let path = profile_data_path.join("Default").join("Cookies"); - if path.exists() { - Ok(path) + let network_path = profile_data_path + .join("Default") + .join("Network") + .join("Cookies"); + let legacy_path = profile_data_path.join("Default").join("Cookies"); + if network_path.exists() { + Ok(network_path) + } else if legacy_path.exists() { + Ok(legacy_path) } else { - Err(format!("Cookie database not found at: {}", path.display())) + Err(format!( + "Cookie database not found at: {}", + network_path.display() + )) } } "camoufox" => { @@ -232,11 +241,21 @@ impl CookieManager { match profile.browser.as_str() { "wayfern" => { - let path = profile_data_path.join("Default").join("Cookies"); - if !path.exists() { - Self::create_empty_chrome_cookies_db(&path)?; + let network_path = profile_data_path + .join("Default") + .join("Network") + .join("Cookies"); + let legacy_path = profile_data_path.join("Default").join("Cookies"); + if network_path.exists() { + Ok(network_path) + } else if legacy_path.exists() { + Ok(legacy_path) + } else { + let dir = network_path.parent().unwrap(); + std::fs::create_dir_all(dir).map_err(|e| format!("Failed to create Network dir: {e}"))?; + Self::create_empty_chrome_cookies_db(&network_path)?; + Ok(network_path) } - Ok(path) } "camoufox" => { let path = profile_data_path.join("cookies.sqlite"); diff --git a/src-tauri/src/sync/engine.rs b/src-tauri/src/sync/engine.rs index 07df318..1376ae5 100644 --- a/src-tauri/src/sync/engine.rs +++ b/src-tauri/src/sync/engine.rs @@ -2344,7 +2344,18 @@ impl SyncEngine { // Verify critical files after download let os_crypt_key_path = profile_dir.join("profile").join("os_crypt_key"); - let cookies_path = profile_dir.join("profile").join("Default").join("Cookies"); + let cookies_path = { + let network = profile_dir + .join("profile") + .join("Default") + .join("Network") + .join("Cookies"); + if network.exists() { + network + } else { + profile_dir.join("profile").join("Default").join("Cookies") + } + }; if os_crypt_key_path.exists() { let key_data = fs::read(&os_crypt_key_path).unwrap_or_default(); log::info!( diff --git a/src-tauri/src/wayfern_manager.rs b/src-tauri/src/wayfern_manager.rs index 5b998a7..39772ee 100644 --- a/src-tauri/src/wayfern_manager.rs +++ b/src-tauri/src/wayfern_manager.rs @@ -519,7 +519,17 @@ impl WayfernManager { { let profile_path_buf = std::path::PathBuf::from(profile_path); let key_path = profile_path_buf.join("os_crypt_key"); - let cookies_path = profile_path_buf.join("Default").join("Cookies"); + let cookies_path = { + let network = profile_path_buf + .join("Default") + .join("Network") + .join("Cookies"); + if network.exists() { + network + } else { + profile_path_buf.join("Default").join("Cookies") + } + }; if key_path.exists() { let key_text = std::fs::read_to_string(&key_path).unwrap_or_default(); @@ -819,6 +829,29 @@ impl WayfernManager { } } + // Clear Playwright's emulation overrides that cause tampering detection + for target in &page_targets { + if let Some(ws_url) = &target.websocket_debugger_url { + let _ = self + .send_cdp_command(ws_url, "Emulation.clearDeviceMetricsOverride", json!({})) + .await; + let _ = self + .send_cdp_command( + ws_url, + "Emulation.setFocusEmulationEnabled", + json!({ "enabled": false }), + ) + .await; + let _ = self + .send_cdp_command( + ws_url, + "Emulation.setEmulatedMedia", + json!({ "media": "", "features": [] }), + ) + .await; + } + } + let id = uuid::Uuid::new_v4().to_string(); let instance = WayfernInstance { id: id.clone(), diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx index b529135..c7f8bde 100644 --- a/src/components/ui/chart.tsx +++ b/src/components/ui/chart.tsx @@ -67,7 +67,12 @@ const ChartContainer = React.forwardRef< {...props} > - + {children}