From 8d33911cc094049b62f6c486f44df51aed1909b5 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 18 Jan 2019 08:34:14 +0200 Subject: [PATCH] Revert --- keepassxc-browser/keepassxc-browser.js | 69 +++++++++++++++++++++++++- keepassxc-browser/manifest.json | 10 ---- keepassxc-browser/requests.js | 69 -------------------------- 3 files changed, 68 insertions(+), 80 deletions(-) delete mode 100644 keepassxc-browser/requests.js diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index da9596c..d9dff0c 100755 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -28,6 +28,74 @@ function _fs(fieldId) { return (field.length > 0) ? field : null; } +browser.runtime.onMessage.addListener(function(req, sender, callback) { + if ('action' in req) { + if (req.action === 'fill_user_pass_with_specific_login') { + if (cip.credentials[req.id]) { + let combination = null; + if (cip.u) { + cip.setValueWithChange(cip.u, cip.credentials[req.id].login); + combination = cipFields.getCombination('username', cip.u); + browser.runtime.sendMessage({ + action: 'page_set_login_id', args: [req.id] + }); + cip.u.focus(); + } + if (cip.p) { + cip.setValueWithChange(cip.p, cip.credentials[req.id].password); + browser.runtime.sendMessage({ + action: 'page_set_login_id', args: [req.id] + }); + combination = cipFields.getCombination('password', cip.p); + } + + let list = []; + if (cip.fillInStringFields(combination.fields, cip.credentials[req.id].stringFields, list)) { + cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]}); + } + } + } else if (req.action === 'fill_user_pass') { + _called.manualFillRequested = 'both'; + cip.receiveCredentialsIfNecessary().then((response) => { + cip.fillInFromActiveElement(false); + }); + } else if (req.action === 'fill_pass_only') { + _called.manualFillRequested = 'pass'; + cip.receiveCredentialsIfNecessary().then((response) => { + cip.fillInFromActiveElement(false, true); // passOnly to true + }); + } else if (req.action === 'fill_totp') { + cip.receiveCredentialsIfNecessary().then((response) => { + cip.fillInFromActiveElementTOTPOnly(false); + }); + } else if (req.action === 'activate_password_generator') { + cip.initPasswordGenerator(cipFields.getAllFields()); + } else if (req.action === 'remember_credentials') { + cip.contextMenuRememberCredentials(); + } else if (req.action === 'choose_credential_fields') { + cipDefine.init(); + } else if (req.action === 'clear_credentials') { + cipEvents.clearCredentials(); + return Promise.resolve(); + } else if (req.action === 'activated_tab') { + cipEvents.triggerActivatedTab(); + return Promise.resolve(); + } else if (req.action === 'redetect_fields') { + browser.runtime.sendMessage({ + action: 'load_settings', + }).then((response) => { + cip.settings = response; + cip.initCredentialFields(true); + }); + } else if (req.action === 'ignore-site') { + cip.ignoreSite(req.args); + } + else if (req.action === 'check_database_hash' && 'hash' in req) { + cip.detectDatabaseChange(req.hash); + } + } +}); + var cipAutocomplete = {}; @@ -1433,7 +1501,6 @@ cip.initCredentialFields = function(forceCall) { } if (cip.settings.autoRetrieveCredentials && _called.retrieveCredentials === false && (cip.url && cip.submitUrl)) { - _called.retrieveCredentials = true; browser.runtime.sendMessage({ action: 'retrieve_credentials', args: [ cip.url, cip.submitUrl ] diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json index e5b0abb..0ac3cc5 100755 --- a/keepassxc-browser/manifest.json +++ b/keepassxc-browser/manifest.json @@ -58,16 +58,6 @@ ], "run_at": "document_idle", "all_frames": true - }, - { - "matches": [ - "" - ], - "js": [ - "requests.js" - ], - "run_at": "document_idle", - "all_frames": false } ], "commands": { diff --git a/keepassxc-browser/requests.js b/keepassxc-browser/requests.js deleted file mode 100644 index 3330264..0000000 --- a/keepassxc-browser/requests.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -browser.runtime.onMessage.addListener(function(req, sender) { - if ('action' in req) { - if (req.action === 'fill_user_pass_with_specific_login') { - if (cip.credentials[req.id]) { - let combination = null; - if (cip.u) { - cip.setValueWithChange(cip.u, cip.credentials[req.id].login); - combination = cipFields.getCombination('username', cip.u); - browser.runtime.sendMessage({ - action: 'page_set_login_id', args: [req.id] - }); - cip.u.focus(); - } - if (cip.p) { - cip.setValueWithChange(cip.p, cip.credentials[req.id].password); - browser.runtime.sendMessage({ - action: 'page_set_login_id', args: [req.id] - }); - combination = cipFields.getCombination('password', cip.p); - } - - let list = []; - if (cip.fillInStringFields(combination.fields, cip.credentials[req.id].stringFields, list)) { - cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]}); - } - } - } else if (req.action === 'fill_user_pass') { - _called.manualFillRequested = 'both'; - cip.receiveCredentialsIfNecessary().then((response) => { - cip.fillInFromActiveElement(false); - }); - } else if (req.action === 'fill_pass_only') { - _called.manualFillRequested = 'pass'; - cip.receiveCredentialsIfNecessary().then((response) => { - cip.fillInFromActiveElement(false, true); // passOnly to true - }); - } else if (req.action === 'fill_totp') { - cip.receiveCredentialsIfNecessary().then((response) => { - cip.fillInFromActiveElementTOTPOnly(false); - }); - } else if (req.action === 'activate_password_generator') { - cip.initPasswordGenerator(cipFields.getAllFields()); - } else if (req.action === 'remember_credentials') { - cip.contextMenuRememberCredentials(); - } else if (req.action === 'choose_credential_fields') { - cipDefine.init(); - } else if (req.action === 'clear_credentials') { - cipEvents.clearCredentials(); - return Promise.resolve(); - } else if (req.action === 'activated_tab') { - cipEvents.triggerActivatedTab(); - return Promise.resolve(); - } else if (req.action === 'redetect_fields') { - browser.runtime.sendMessage({ - action: 'load_settings', - }).then((response) => { - cip.settings = response; - cip.initCredentialFields(true); - }); - } else if (req.action === 'ignore-site') { - cip.ignoreSite(req.args); - } - else if (req.action === 'check_database_hash' && 'hash' in req) { - cip.detectDatabaseChange(req.hash); - } - } -});