diff --git a/chromeKeePassXC/background/init.js b/chromeKeePassXC/background/init.js index 242c719..606f783 100644 --- a/chromeKeePassXC/background/init.js +++ b/chromeKeePassXC/background/init.js @@ -7,8 +7,7 @@ page.initOpenedTabs(); // initial connection with KeePassXC keepass.connectToNative(); keepass.generateNewKeyPair(); -//keepass.getDatabaseHash(null, null); -//keepass.changePublicKeys(); +keepass.changePublicKeys(); keepass.getDatabaseHash(function(res) { keepass.changePublicKeys(); }, null); @@ -148,6 +147,26 @@ chrome.contextMenus.create({ } }); +/** + * Listen for keyboard shortcuts specified by user + */ +chrome.commands.onCommand.addListener(function(command) { + if (command === "fill-username-password") { + chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { + if (tabs.length) { + chrome.tabs.sendMessage(tabs[0].id, { action: "fill_user_pass" }); + } + }); + } + + if (command === "fill-password") { + chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { + if (tabs.length) { + chrome.tabs.sendMessage(tabs[0].id, { action: "fill_pass_only" }); + } + }); + } +}); /** * Interval which updates the browserAction (e.g. blinking icon) diff --git a/chromeKeePassXC/background/keepass.js b/chromeKeePassXC/background/keepass.js index f7fa77a..097ef00 100644 --- a/chromeKeePassXC/background/keepass.js +++ b/chromeKeePassXC/background/keepass.js @@ -480,7 +480,7 @@ keepass.getDatabaseHash = function (callback, tab, triggerUnlock) { } keepass.changePublicKeys = function(tab) { - if (!keepass.isConnected || !keepass.databaseHash || keepass.databaseHash !== "no-hash") { + if (!keepass.isConnected || keepass.serverPublicKey) { return; } diff --git a/chromeKeePassXC/chromekeepassxc.js b/chromeKeePassXC/chromekeepassxc.js index c729e42..1179b6e 100644 --- a/chromeKeePassXC/chromekeepassxc.js +++ b/chromeKeePassXC/chromekeepassxc.js @@ -58,26 +58,6 @@ chrome.extension.onMessage.addListener(function(req, sender, callback) { } }); -// Hotkeys for every page -// ctrl + shift + p = fill only password -// ctrl + shift + u = fill username + password -window.addEventListener("keydown", function(e) { - if (e.ctrlKey && e.shiftKey) { - if (e.key == "KeyP" || e.keyIdentifier == "U+0050") { // P - e.preventDefault(); - cip.receiveCredentialsIfNecessary(); - cip.fillInFromActiveElementPassOnly(false); - } else if (e.key == "KeyU" || e.keyIdentifier == "U+0055") { // U - e.preventDefault(); - cip.receiveCredentialsIfNecessary(); - cip.fillInFromActiveElement(false); - var field =_f(cipFields.combinations[0].username); - cipAutocomplete.init(field); - field.click(); - } - } -}, false); - function _f(fieldId) { var field = (fieldId) ? jQuery("input[data-cip-id='"+fieldId+"']:first") : []; return (field.length > 0) ? field : null; @@ -1168,12 +1148,12 @@ cip.initCredentialFields = function(forceCall) { cip.url = document.location.origin; cip.submitUrl = cip.getFormActionUrl(cipFields.combinations[0]); - if (cip.settings.autoRetrieveCredentials) { - chrome.extension.sendMessage({ - 'action': 'retrieve_credentials', - 'args': [ cip.url, cip.submitUrl ] - }, cip.retrieveCredentialsCallback); - } + if (cip.settings.autoRetrieveCredentials) { + chrome.extension.sendMessage({ + 'action': 'retrieve_credentials', + 'args': [ cip.url, cip.submitUrl ] + }, cip.retrieveCredentialsCallback); + } } // end function init cip.initPasswordGenerator = function(inputs) { diff --git a/chromeKeePassXC/manifest.json b/chromeKeePassXC/manifest.json index fa1e493..fde8909 100644 --- a/chromeKeePassXC/manifest.json +++ b/chromeKeePassXC/manifest.json @@ -1,6 +1,6 @@ { "name": "chromeKeePassXC", - "version": "0.1.0", + "version": "0.1.1", "manifest_version": 2, "description": "KeePassXC integration for Chrome", "icons": { @@ -53,6 +53,22 @@ "all_frames": true } ], + "commands": { + "fill-username-password": { + "description": "Insert username + password", + "suggested_key": { + "default": "Ctrl+Shift+U", + "mac": "Command+Shift+U" + } + }, + "fill-password": { + "description": "Insert a password", + "suggested_key": { + "default": "Ctrl+Shift+P", + "mac": "Command+Shift+P" + } + } + }, "web_accessible_resources": [ "jquery.min.map", "icons/key_16x16.png", diff --git a/chromeKeePassXC/options/options.html b/chromeKeePassXC/options/options.html index 9ebeb79..ac690a2 100644 --- a/chromeKeePassXC/options/options.html +++ b/chromeKeePassXC/options/options.html @@ -27,9 +27,9 @@

General Settings


- If you just want to insert username + password into the fields where your focus is, press Ctrl + Shift + U. + If you just want to insert username + password into the fields where your focus is, press Ctrl + Shift + U.
- If you only want to insert the password, just press Ctrl + Shift + P. + If you only want to insert the password, just press Ctrl + Shift + P. You can customize these shortcuts on chrome://extensions/configureCommands page