mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Modifications to Redetect Fields
This commit is contained in:
parent
0c1aa0e387
commit
00f0ee658e
4 changed files with 34 additions and 11 deletions
|
|
@ -24,13 +24,12 @@ kpxcEvent.showStatus = async function(tab, configured, internalPoll) {
|
|||
browserAction.showDefault(tab);
|
||||
}
|
||||
|
||||
const errorMessage = page.tabs[tab.id]?.errorMessage ?? undefined;
|
||||
const usernameFieldDetected = page.tabs[tab.id]?.usernameFieldDetected ?? false;
|
||||
const iframeDetected = page.tabs[tab.id]?.iframeDetected ?? false;
|
||||
const errorMessage = await page.getTabErrorMessage(tab);
|
||||
const usernameFieldDetected = await page.isUsernameFieldDetected(tab);
|
||||
const iframeDetected = await page.isIframeDetected(tab);
|
||||
|
||||
return {
|
||||
associated: keepass.isAssociated(),
|
||||
|
||||
configured: configured,
|
||||
databaseClosed: keepass.isDatabaseClosed,
|
||||
encryptionKeyUnrecognized: keepass.isEncryptionKeyUnrecognized,
|
||||
|
|
@ -117,8 +116,7 @@ kpxcEvent.lockDatabase = async function(tab) {
|
|||
};
|
||||
|
||||
kpxcEvent.onGetTabInformation = async function(tab) {
|
||||
const id = tab?.id || page.currentTabId;
|
||||
return page.tabs[id];
|
||||
return await page.getTabInformation(tab);
|
||||
};
|
||||
|
||||
kpxcEvent.onGetConnectedDatabase = async function() {
|
||||
|
|
@ -176,8 +174,8 @@ kpxcEvent.onHTTPAuthPopup = async function(tab, data) {
|
|||
await browserAction.show(tab, popupData);
|
||||
};
|
||||
|
||||
kpxcEvent.onUsernameFieldDetected = async function(tab, detected) {
|
||||
page.tabs[tab.id].usernameFieldDetected = detected;
|
||||
kpxcEvent.onUsernameFieldDetected = async function(tab, args = []) {
|
||||
await page.setUsernameFieldDetected(tab, args[0], args[1]);
|
||||
};
|
||||
|
||||
kpxcEvent.onIframeDetected = async function(tab, detected) {
|
||||
|
|
|
|||
|
|
@ -385,6 +385,30 @@ page.isIframeAllowed = async function(tab, args = []) {
|
|||
return hostname.endsWith(baseDomain) && tabUrl.hostname?.endsWith(baseDomain);
|
||||
};
|
||||
|
||||
page.isIframeDetected = async function(tab) {
|
||||
return page.tabs[tab.id]?.iframeDetected ?? false;
|
||||
};
|
||||
|
||||
page.isUsernameFieldDetected = async function(tab) {
|
||||
return page.tabs[tab.id]?.usernameFieldDetected ?? false;
|
||||
};
|
||||
|
||||
// Only set if the content script URL matches
|
||||
page.setUsernameFieldDetected = async function(tab, detected, url) {
|
||||
if (url === tab?.url) {
|
||||
page.tabs[tab.id].usernameFieldDetected = detected;
|
||||
}
|
||||
};
|
||||
|
||||
page.getTabErrorMessage = async function(tab) {
|
||||
return page.tabs[tab.id]?.errorMessage ?? undefined;
|
||||
};
|
||||
|
||||
page.getTabInformation = async function(tab) {
|
||||
const id = tab?.id || page.currentTabId;
|
||||
return page.tabs[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the top level domain from URL.
|
||||
* @param {string} domain Current iframe's hostname
|
||||
|
|
|
|||
|
|
@ -215,9 +215,9 @@ kpxcFields.getAllPageInputs = async function(previousInputs = []) {
|
|||
if (!kpxc.singleInputEnabledForPage
|
||||
&& ((fields.length === 1 && fields[0].getLowerCaseAttribute('type') !== 'password')
|
||||
|| (previousInputs.length === 1 && previousInputs[0].getLowerCaseAttribute('type') !== 'password'))) {
|
||||
sendMessage('username_field_detected', true);
|
||||
await sendMessage('username_field_detected', [ true, document.location.href ]);
|
||||
} else {
|
||||
sendMessage('username_field_detected', false);
|
||||
await sendMessage('username_field_detected', [ false, document.location.href ]);
|
||||
}
|
||||
|
||||
await kpxc.initCombinations(inputs);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ const sendMessageToTab = async function(message) {
|
|||
}
|
||||
|
||||
statusResponse(await browser.runtime.sendMessage({
|
||||
action: 'get_status'
|
||||
action: 'get_status',
|
||||
args: [ true ]
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue