-
Notifications
You must be signed in to change notification settings - Fork 1k
add autofill command #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add autofill command #831
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ import { Encryption } from "./models/encryption"; | |
| import { EntryStorage, ManagedStorage } from "./models/storage"; | ||
| import { Dropbox, Drive, OneDrive } from "./models/backup"; | ||
| import * as uuid from "uuid/v4"; | ||
| import { getSiteName, getMatchedEntries } from "./utils"; | ||
| import { CodeState } from "./models/otp"; | ||
|
|
||
| import { getOTPAuthPerLineFromOPTAuthMigration } from "./models/migration"; | ||
|
|
||
|
|
@@ -560,6 +562,59 @@ chrome.commands.onCommand.addListener(async (command: string) => { | |
| }); | ||
| break; | ||
|
|
||
| case "autofill": | ||
| await new Promise( | ||
| (resolve: () => void, reject: (reason: Error) => void) => { | ||
| try { | ||
| return chrome.tabs.executeScript( | ||
| { file: "/dist/content.js" }, | ||
| () => { | ||
| chrome.tabs.insertCSS({ file: "/css/content.css" }, resolve); | ||
| } | ||
| ); | ||
| } catch (error) { | ||
| console.error(error); | ||
| return reject(error); | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| if (cachedPassphrase === "") { | ||
| return; | ||
| } | ||
|
|
||
| chrome.tabs.query( | ||
| { active: true, lastFocusedWindow: true }, | ||
| async (tabs) => { | ||
| const tab = tabs[0]; | ||
| if (!tab || !tab.id) { | ||
| return; | ||
| } | ||
| contentTab = tab; | ||
|
|
||
| const siteName = await getSiteName(); | ||
| const entries = await EntryStorage.get(); | ||
| const matchedEntries = getMatchedEntries(siteName, entries); | ||
|
|
||
| if (matchedEntries && matchedEntries.length === 1) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. matchedEntries.length <= 1
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, incorrect logic on my end. I meant
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is more than one matched entry I think we should always ask the user to choose the correct one, but not the first one. What do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, that would be the best solution.
This comment was marked as duplicate.
Sorry, something went wrong. |
||
| const entry = matchedEntries[0]; | ||
| const encryption = new Encryption(cachedPassphrase); | ||
| entry.applyEncryption(encryption); | ||
|
|
||
| if ( | ||
| entry.code !== CodeState.Encrypted && | ||
| entry.code !== CodeState.Invalid | ||
| ) { | ||
| chrome.tabs.sendMessage(tab.id, { | ||
| action: "pastecode", | ||
| code: matchedEntries[0].code, | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| ); | ||
| break; | ||
|
|
||
| default: | ||
| break; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.