Merge pull request #2293 from keepassxreboot/fix/predefined_improved_input_field_detection

Add Improved Input Field Detection to Predefined Sites feature
This commit is contained in:
Sami Vänttinen 2024-07-28 07:41:11 +03:00 committed by GitHub
commit 892e80fa2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 7 deletions

View file

@ -118,6 +118,7 @@
"IGNORE_NORMAL": true, "IGNORE_NORMAL": true,
"IGNORE_NOTHING": true, "IGNORE_NOTHING": true,
"importScripts": true, "importScripts": true,
"IMPROVED_DETECTION_PREDEFINED_SITELIST": true,
"initColorTheme": true, "initColorTheme": true,
"isEdge": true, "isEdge": true,
"isFirefox": true, "isFirefox": true,

View file

@ -34,6 +34,10 @@ const PREDEFINED_SITELIST = [
'https://*.wordpress.com/log-in/' 'https://*.wordpress.com/log-in/'
]; ];
const IMPROVED_DETECTION_PREDEFINED_SITELIST = [
'https://secure.chase.com/*'
];
const googleUrl = 'https://accounts.google.com'; const googleUrl = 'https://accounts.google.com';
const kpxcSites = {}; const kpxcSites = {};

View file

@ -747,7 +747,7 @@ kpxc.showGroupNameInAutocomplete = function() {
|| (kpxc.settings.showGroupNameInAutocomplete && kpxc.getUniqueGroupCount(kpxc.credentials) > 1); || (kpxc.settings.showGroupNameInAutocomplete && kpxc.getUniqueGroupCount(kpxc.credentials) > 1);
}; };
// Returns true if site is ignored // Returns true if site is ignored, and checks for predefined sites
kpxc.siteIgnored = async function(condition) { kpxc.siteIgnored = async function(condition) {
if (kpxc.settings.sitePreferences) { if (kpxc.settings.sitePreferences) {
let currentLocation; let currentLocation;
@ -760,7 +760,6 @@ kpxc.siteIgnored = async function(condition) {
currentLocation = window.self.location.href; currentLocation = window.self.location.href;
} }
// Refresh current settings for the site
const currentSetting = condition || IGNORE_FULL; const currentSetting = condition || IGNORE_FULL;
for (const site of kpxc.settings.sitePreferences) { for (const site of kpxc.settings.sitePreferences) {
if (siteMatch(site.url, currentLocation) || site.url === currentLocation) { if (siteMatch(site.url, currentLocation) || site.url === currentLocation) {
@ -768,6 +767,7 @@ kpxc.siteIgnored = async function(condition) {
return true; return true;
} }
// Refresh current settings for the site
kpxc.singleInputEnabledForPage = site.usernameOnly; kpxc.singleInputEnabledForPage = site.usernameOnly;
kpxc.improvedFieldDetectionEnabledForPage = site.improvedFieldDetection; kpxc.improvedFieldDetectionEnabledForPage = site.improvedFieldDetection;
await sendMessage('page_set_allow_iframes', [ site.allowIframes, currentLocation ]); await sendMessage('page_set_allow_iframes', [ site.allowIframes, currentLocation ]);
@ -776,11 +776,7 @@ kpxc.siteIgnored = async function(condition) {
// Check for predefined sites // Check for predefined sites
if (kpxc.settings.usePredefinedSites) { if (kpxc.settings.usePredefinedSites) {
for (const url of PREDEFINED_SITELIST) { kpxc.usePredefinedSites(currentLocation);
if (siteMatch(url, currentLocation) || url === currentLocation) {
kpxc.singleInputEnabledForPage = true;
}
}
} }
} }
@ -843,6 +839,23 @@ kpxc.updateTOTPList = async function() {
return []; return [];
}; };
// Enable certain settings based on predefined sites list
kpxc.usePredefinedSites = function(currentLocation) {
// Single input field
for (const url of PREDEFINED_SITELIST) {
if (siteMatch(url, currentLocation) || url === currentLocation) {
kpxc.singleInputEnabledForPage = true;
}
}
// Improved input field detection
for (const url of IMPROVED_DETECTION_PREDEFINED_SITELIST) {
if (siteMatch(url, currentLocation) || url === currentLocation) {
kpxc.improvedFieldDetectionEnabledForPage = true;
}
}
};
// Apply a script to the page for intercepting Passkeys (WebAuthn) requests // Apply a script to the page for intercepting Passkeys (WebAuthn) requests
kpxc.enablePasskeys = function() { kpxc.enablePasskeys = function() {
if (document?.documentElement?.ownerDocument?.contentType !== 'text/html') { if (document?.documentElement?.ownerDocument?.contentType !== 'text/html') {