musealpha / src-tauri /src /browser /autofill.rs
asdf98's picture
Upload 112 files
3d7d9b5 verified
use tauri::AppHandle;
use super::tab_manager::eval_on_tab;
/// Injects saved credentials into the active child webview's login form.
/// Called by the React frontend after user selects a credential from the vault.
/// Uses the __museAutofill() function that vault_detector.js defines in every page.
#[tauri::command]
pub fn tab_autofill(app: AppHandle, tab_id: String, username: String, password: String) -> Result<(), String> {
let username_js = serde_json::to_string(&username).map_err(|e| e.to_string())?;
let password_js = serde_json::to_string(&password).map_err(|e| e.to_string())?;
let js = format!("window.__museAutofill && window.__museAutofill({username_js}, {password_js})");
eval_on_tab(&app, &tab_id, &js)
}