blob: 0c51b067d38e639325cdaf392434f241d13e2001 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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>
|