diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-09-26 12:40:58 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-09-26 12:40:58 +0200 |
| commit | a996f78277d5ba5adccb0daa535bc2494350975c (patch) | |
| tree | 08d594ba144f41fb14ebd2354beb2a8cda9be101 /webext/firefox/popup.html | |
| parent | 91499edd42cc50ee0543e11e08a6b653f3475262 (diff) | |
| download | cerberus-a996f78277d5ba5adccb0daa535bc2494350975c.tar.gz cerberus-a996f78277d5ba5adccb0daa535bc2494350975c.zip | |
Initial Commit
Diffstat (limited to 'webext/firefox/popup.html')
| -rw-r--r-- | webext/firefox/popup.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/webext/firefox/popup.html b/webext/firefox/popup.html new file mode 100644 index 0000000..0c51b06 --- /dev/null +++ b/webext/firefox/popup.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8" /> + <title>Cerberus</title> + <style> + body { font-family: sans-serif; width: 280px; margin: 10px; } + button { width: 100%; padding: 8px; margin: 6px 0; } + input { width: 100%; padding: 6px; margin: 6px 0; } + </style> +</head> +<body> + <h3>Cerberus</h3> + <input id="username" placeholder="Username" /> + <input id="password" placeholder="Password" type="password" /> + <button id="fetch">Fetch from Vault</button> + <button id="fill">Fill on Page</button> + <div id="status" style="font-size: 12px; color: #666; margin-top: 6px;"></div> + <script> + async function getActiveTab() { + const tabs = await browser.tabs.query({ active: true, currentWindow: true }); + return tabs[0]; + } + + async function fill(username, password) { + const tab = await getActiveTab(); + await browser.tabs.sendMessage(tab.id, { type: 'FILL_CREDENTIALS', payload: { username, password } }); + } + + document.getElementById('fill').addEventListener('click', async () => { + const username = document.getElementById('username').value; + const password = document.getElementById('password').value; + try { + await fill(username, password); + window.close(); + } catch (e) { console.error(e); } + }); + + document.getElementById('fetch').addEventListener('click', async () => { + const status = document.getElementById('status'); + status.textContent = 'Fetching credentials from vault...'; + try { + const resp = await browser.runtime.sendMessage({ type: 'GET_CREDENTIALS_FOR_TAB' }); + if (!resp || !resp.ok) { + status.textContent = 'Failed to fetch (is native host installed and unlocked?)'; + return; + } + const results = resp.result || []; + if (results.length === 0) { + status.textContent = 'No entries matched for this origin'; + return; + } + // Choose the first match (later: add a dropdown) + const { username, password } = results[0]; + if (username) document.getElementById('username').value = username; + if (password) document.getElementById('password').value = password; + status.textContent = 'Fetched from vault'; + } catch (e) { + console.error(e); + status.textContent = 'Error fetching credentials'; + } + }); + </script> +</body> +</html> |
