diff --git a/addKey.html b/addKey.html index 1b7afd3..9442516 100644 --- a/addKey.html +++ b/addKey.html @@ -74,7 +74,12 @@

Add Key

- +
+ + +
<,./-='; + let password = ''; + + for (let i = 0; i < length; i++) { + const randomIndex = Math.floor(Math.random() * charset.length); + password += charset[randomIndex]; + } + document.getElementById('password').value = password; + + copyStringToClipboard(password); + + notify.success('Generated password copied to clipboard!', { time: 5000 }); +} + function handleCancel() { window.location.href = '/popup.html'; } diff --git a/common.js b/common.js index ed94c06..19136dc 100644 --- a/common.js +++ b/common.js @@ -20,3 +20,17 @@ function storePathComponents(storePath) { if (!browser.browserAction) { browser.browserAction = chrome.browserAction ?? chrome.action; } + +async function copyStringToClipboard(string) { + const tabs = await browser.tabs.query({ active: true, currentWindow: true }); + for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) { + const tab = tabs[tabIndex]; + if (tab.url) { + browser.tabs.sendMessage(tab.id, { + message: 'copy_to_clipboard', + string: string, + }); + break; + } + } +} diff --git a/popup.js b/popup.js index fd2cb60..47a663e 100644 --- a/popup.js +++ b/popup.js @@ -1,5 +1,5 @@ /* eslint-disable no-prototype-builtins */ -/* global Notify storePathComponents */ +/* global Notify storePathComponents,copyStringToClipboard */ const notify = new Notify(document.querySelector('#notify')); const resultList = document.getElementById('resultList'); @@ -293,20 +293,6 @@ async function fillCredentialsInBrowser(username, password) { } } -async function copyStringToClipboard(string) { - const tabs = await browser.tabs.query({ active: true, currentWindow: true }); - for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) { - const tab = tabs[tabIndex]; - if (tab.url) { - browser.tabs.sendMessage(tab.id, { - message: 'copy_to_clipboard', - string: string, - }); - break; - } - } -} - async function deleteCredentials(secretPath) { const result = await fetch(`${vaultServerAddress}/v1/${secretPath}`, { method: 'DELETE', diff --git a/style.css b/style.css index 2bbcc29..e65cbcc 100644 --- a/style.css +++ b/style.css @@ -233,6 +233,11 @@ main { .form-group { margin-bottom: var(--space-lg); } +.password-row { + display: flex; + align-items: center; + justify-content: space-between; +} .label { display: block; margin-bottom: var(--space-sm);