From 359c8d445149ed84a636bdd38414b9554281e9ce Mon Sep 17 00:00:00 2001 From: Sexfrance Date: Sun, 27 Jul 2025 12:21:18 +0300 Subject: [PATCH 1/2] Added automatic code copying upon scanning qr code --- src/background.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/background.ts b/src/background.ts index bb59a2f9..9602db2a 100644 --- a/src/background.ts +++ b/src/background.ts @@ -232,8 +232,23 @@ async function getTotp(text: string, silent = false) { !silent && chrome.tabs.sendMessage(id, { action: "errorenc" }); return false; } - await EntryStorage.import(encryption, entryData); - !silent && chrome.tabs.sendMessage(id, { action: "added", account }); + wait EntryStorage.import(encryption, entryData); + + const newEntry = await EntryStorage.get(hash); + newEntry.applyEncryption(encryption); + + if (newEntry.code && newEntry.code !== CodeState.Encrypted && newEntry.code !== CodeState.Invalid) { + try { + await navigator.clipboard.writeText(newEntry.code); + console.log(`TOTP code copied to clipboard: ${newEntry.code}`); + !silent && chrome.tabs.sendMessage(id, { action: "addedAndCopied", account, code: newEntry.code }); + } catch (e) { + console.error("Failed to copy TOTP code:", e); + !silent && chrome.tabs.sendMessage(id, { action: "added", account }); + } + } else { + !silent && chrome.tabs.sendMessage(id, { action: "added", account }); + } return true; } } From f32b321d658934a5f6adff6439cc3f53c159ddca Mon Sep 17 00:00:00 2001 From: Sexfrance Date: Sun, 27 Jul 2025 12:26:29 +0300 Subject: [PATCH 2/2] Fixed typo --- src/background.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background.ts b/src/background.ts index 9602db2a..3a298d0e 100644 --- a/src/background.ts +++ b/src/background.ts @@ -232,7 +232,7 @@ async function getTotp(text: string, silent = false) { !silent && chrome.tabs.sendMessage(id, { action: "errorenc" }); return false; } - wait EntryStorage.import(encryption, entryData); + await EntryStorage.import(encryption, entryData); const newEntry = await EntryStorage.get(hash); newEntry.applyEncryption(encryption);