Merge pull request #387 from keepassxreboot/fix_371

Revert #371
This commit is contained in:
Sami Vänttinen 2019-02-05 10:11:19 +02:00 committed by GitHub
commit 7f3711e382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 80 deletions

View file

@ -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 ]

View file

@ -58,16 +58,6 @@
],
"run_at": "document_idle",
"all_frames": true
},
{
"matches": [
"<all_urls>"
],
"js": [
"requests.js"
],
"run_at": "document_idle",
"all_frames": false
}
],
"commands": {

View file

@ -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);
}
}
});