aboutsummaryrefslogtreecommitdiff
path: root/webext/chrome/popup.html
diff options
context:
space:
mode:
Diffstat (limited to 'webext/chrome/popup.html')
-rw-r--r--webext/chrome/popup.html56
1 files changed, 56 insertions, 0 deletions
diff --git a/webext/chrome/popup.html b/webext/chrome/popup.html
new file mode 100644
index 0000000..b3482ed
--- /dev/null
+++ b/webext/chrome/popup.html
@@ -0,0 +1,56 @@
+<!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 chrome.tabs.query({ active: true, currentWindow: true });
+ return tabs[0];
+ }
+ function sendToBackground(msg) {
+ return new Promise((resolve) => {
+ chrome.runtime.sendMessage(msg, resolve);
+ });
+ }
+ async function fill(username, password) {
+ await sendToBackground({ 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 sendToBackground({ type: 'GET_CREDENTIALS_FOR_TAB' });
+ if (!resp || !resp.ok) { status.textContent = 'Failed to fetch (native host?)'; return; }
+ const results = resp.result || [];
+ if (results.length === 0) { status.textContent = 'No matching entries'; return; }
+ 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'; }
+ });
+ </script>
+</body>
+</html>