mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Remove document event overrides
This commit is contained in:
parent
03020bb58d
commit
96523cd31a
5 changed files with 52 additions and 60 deletions
|
|
@ -421,7 +421,6 @@ keepass.testAssociation = async function(callback, tab, enableTimeout = false, t
|
|||
|
||||
if (!keepass.isKeePassXCAvailable && !page.settings.automaticReconnect) {
|
||||
try {
|
||||
keepass.connectToNative();
|
||||
await keepass.reconnect();
|
||||
} catch (err) {
|
||||
keepass.handleError(tab, kpErrors.PUBLIC_KEY_NOT_FOUND);
|
||||
|
|
@ -973,8 +972,10 @@ function onDisconnected() {
|
|||
keepass.isKeePassXCAvailable = false;
|
||||
keepass.associated.value = false;
|
||||
keepass.associated.hash = null;
|
||||
keepass.databaseHash = '';
|
||||
page.clearCredentials(page.currentTabId, true);
|
||||
keepass.updatePopup('cross');
|
||||
keepass.updateDatabaseHashToContent();
|
||||
console.log('Failed to connect: ' + (browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message));
|
||||
}
|
||||
|
||||
|
|
@ -1004,6 +1005,7 @@ keepass.nativeConnect = function() {
|
|||
keepass.nativePort.onMessage.addListener(keepass.onNativeMessage);
|
||||
keepass.nativePort.onDisconnect.addListener(onDisconnected);
|
||||
keepass.isConnected = true;
|
||||
return keepass.nativePort;
|
||||
};
|
||||
|
||||
keepass.verifyKeyResponse = function(response, key, nonce) {
|
||||
|
|
@ -1137,10 +1139,9 @@ keepass.enableAutomaticReconnect = function() {
|
|||
}
|
||||
|
||||
if (keepass.reconnectLoop === null) {
|
||||
keepass.reconnectLoop = setInterval(() => {
|
||||
keepass.reconnectLoop = setInterval(async() => {
|
||||
if (!keepass.isKeePassXCAvailable) {
|
||||
keepass.connectToNative();
|
||||
keepass.reconnect().catch((e) => {});
|
||||
keepass.reconnect();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -1151,24 +1152,12 @@ keepass.disableAutomaticReconnect = function() {
|
|||
keepass.reconnectLoop = null;
|
||||
};
|
||||
|
||||
keepass.reconnect = function(callback, tab) {
|
||||
return new Promise((resolve, reject) => {
|
||||
keepass.generateNewKeyPair();
|
||||
keepass.changePublicKeys(tab, true).then((pkRes) => {
|
||||
keepass.getDatabaseHash((gdRes) => {
|
||||
keepass.testAssociation((response) => {
|
||||
keepass.isConfigured().then((configured) => {
|
||||
resolve(configured);
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
reject(e);
|
||||
});
|
||||
}, tab);
|
||||
}, null);
|
||||
}).catch((e) => {
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
keepass.reconnect = async function(callback, tab) {
|
||||
////keepass.connectToNative();
|
||||
const port = keepass.nativeConnect();
|
||||
console.log(port);
|
||||
keepass.generateNewKeyPair();
|
||||
keepass.changePublicKeys(tab, true).then(r => true).catch(e => false);
|
||||
};
|
||||
|
||||
keepass.updatePopup = function(iconType) {
|
||||
|
|
@ -1184,21 +1173,24 @@ keepass.updateDatabase = function() {
|
|||
keepass.testAssociation((associationResponse) => {
|
||||
keepass.isConfigured().then((configured) => {
|
||||
keepass.updatePopup(configured ? 'normal' : 'cross');
|
||||
|
||||
// Send message to content script
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, {
|
||||
action: 'check_database_hash',
|
||||
hash: { old: keepass.previousDatabaseHash, new: keepass.databaseHash }
|
||||
});
|
||||
keepass.previousDatabaseHash = keepass.databaseHash;
|
||||
}
|
||||
});
|
||||
keepass.updateDatabaseHashToContent();
|
||||
});
|
||||
}, null);
|
||||
};
|
||||
|
||||
keepass.updateDatabaseHashToContent = function() {
|
||||
// Send message to content script
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, {
|
||||
action: 'check_database_hash',
|
||||
hash: { old: keepass.previousDatabaseHash, new: keepass.databaseHash }
|
||||
});
|
||||
keepass.previousDatabaseHash = keepass.databaseHash;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
keepass.compareVersion = function(minimum, current, canBeEqual = true) {
|
||||
if (!minimum || !current) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -194,21 +194,21 @@ kpxcDefine.markFields = function(chooser, pattern) {
|
|||
field.style.width = rect.width + 'px';
|
||||
field.style.height = rect.height + 'px';
|
||||
field.textContent = String(index);
|
||||
field.onclick = function(e) {
|
||||
field.addEventListener('click', function(e) {
|
||||
kpxcDefine.eventFieldClick(e);
|
||||
};
|
||||
field.onmouseenter = function() {
|
||||
});
|
||||
field.addEventListener('mouseenter', function() {
|
||||
field.classList.add('kpxcDefine-fixed-hover-field');
|
||||
};
|
||||
field.onmouseleave = function() {
|
||||
});
|
||||
field.addEventListener('mouseleave', function() {
|
||||
field.classList.remove('kpxcDefine-fixed-hover-field');
|
||||
};
|
||||
i.onfocus = function() {
|
||||
});
|
||||
i.addEventListener('focus', function() {
|
||||
field.classList.add('kpxcDefine-fixed-hover-field');
|
||||
};
|
||||
i.onblur = function() {
|
||||
});
|
||||
i.addEventListener('blur', function() {
|
||||
field.classList.remove('kpxcDefine-fixed-hover-field');
|
||||
};
|
||||
});
|
||||
const elem = $(chooser);
|
||||
if (elem) {
|
||||
elem.append(field);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ kpxcForm.destroy = function(form, credentialFields) {
|
|||
}
|
||||
|
||||
if (form && form.length > 0) {
|
||||
form.onsubmit = null;
|
||||
form.removeEventListener('submit', kpxcForm.onSubmit);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -519,9 +519,9 @@ kpxcFields.prepareCombinations = function(combinations) {
|
|||
// Needed for auto-complete: don't overwrite manually filled-in password field
|
||||
if (pwField && !pwField.getAttribute('kpxcFields-onChange')) {
|
||||
pwField.setAttribute('kpxcFields-onChange', true);
|
||||
pwField.onchange = function() {
|
||||
pwField.addEventListener('change', function() {
|
||||
this.setAttribute('unchanged', false);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize form-submit for remembering credentials
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ kpxcPassword.createDialog = function() {
|
|||
const dialog = kpxcUI.createElement('div', 'kpxc kpxc-pwgen-dialog');
|
||||
const titleBar = kpxcUI.createElement('div', 'kpxc-pwgen-titlebar', {}, tr('passwordGeneratorTitle'));
|
||||
const closeButton = kpxcUI.createElement('div', 'kpxc-pwgen-close', {}, '×');
|
||||
closeButton.onclick = function(e) {
|
||||
closeButton.addEventListener('click', function(e) {
|
||||
kpxcPassword.openDialog();
|
||||
};
|
||||
});
|
||||
titleBar.append(closeButton);
|
||||
|
||||
const passwordRow = kpxcUI.createElement('div', 'kpxc-pwgen-password-row');
|
||||
|
|
@ -160,17 +160,17 @@ kpxcPassword.createDialog = function() {
|
|||
const copyButton = kpxcUI.createElement('button', 'kpxc-button', { 'id': 'kpxc-pwgen-btn-copy' }, tr('passwordGeneratorCopy'));
|
||||
const fillButton = kpxcUI.createElement('button', 'kpxc-button', { 'id': 'kpxc-pwgen-btn-fill' }, tr('passwordGeneratorFillAndCopy'));
|
||||
|
||||
generateButton.onclick = function(e) {
|
||||
generateButton.addEventListener('click', function(e) {
|
||||
kpxcPassword.generate(e);
|
||||
};
|
||||
});
|
||||
|
||||
copyButton.onclick = function(e) {
|
||||
copyButton.addEventListener('click', function(e) {
|
||||
kpxcPassword.copy(e);
|
||||
};
|
||||
});
|
||||
|
||||
fillButton.onclick = function(e) {
|
||||
fillButton.addEventListener('click', function(e) {
|
||||
kpxcPassword.fill(e);
|
||||
};
|
||||
});
|
||||
|
||||
buttonsRow.appendMultiple(generateButton, copyButton, fillButton);
|
||||
dialog.appendMultiple(titleBar, passwordRow, nextFillRow, buttonsRow);
|
||||
|
|
@ -184,9 +184,9 @@ kpxcPassword.createDialog = function() {
|
|||
|
||||
kpxcPassword.dialog = dialog;
|
||||
kpxcPassword.titleBar = titleBar;
|
||||
kpxcPassword.titleBar.onmousedown = function(e) {
|
||||
kpxcPassword.titleBar.addEventListener('mousedown', function(e) {
|
||||
kpxcPassword.mouseDown(e);
|
||||
};
|
||||
});
|
||||
|
||||
kpxcPassword.generate();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ kpxcUI.createElement = function(type, classes, attributes, textContent) {
|
|||
};
|
||||
|
||||
// Enables dragging
|
||||
document.onmousemove = function(e) {
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
if (kpxcPassword.selected === kpxcPassword.titleBar) {
|
||||
const xPos = e.clientX - kpxcPassword.diffX;
|
||||
const yPos = e.clientY - kpxcPassword.diffY;
|
||||
|
|
@ -52,12 +52,12 @@ document.onmousemove = function(e) {
|
|||
kpxcDefine.dialog.style.top = yPos + 'px';
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
document.onmouseup = function() {
|
||||
document.addEventListener('mouseup', function() {
|
||||
kpxcPassword.selected = null;
|
||||
kpxcDefine.selected = null;
|
||||
};
|
||||
});
|
||||
|
||||
HTMLDivElement.prototype.appendMultiple = function(...args) {
|
||||
for (const a of args) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue