From 426f2b191cce3be06a223ee93f7d2e7b7fac5b11 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 19 Aug 2025 09:49:58 +0300 Subject: [PATCH] Fix opacity checks --- keepassxc-browser/content/fields.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/keepassxc-browser/content/fields.js b/keepassxc-browser/content/fields.js index 8b610ed..70f0258 100644 --- a/keepassxc-browser/content/fields.js +++ b/keepassxc-browser/content/fields.js @@ -413,6 +413,12 @@ kpxcFields.isSearchField = function(target) { // Returns true if element is visible on the page kpxcFields.isVisible = function(elem) { + // Returns true if opacity is not set, otherwise check the limits + const isOpacityAllowed = (opacity) => { + const opac = Number(opacity); + return opacity === '' || (opac >= MIN_OPACITY && opac <= MAX_OPACITY); + }; + // Check element position and size const rect = elem.getBoundingClientRect(); if (rect.x < 0 @@ -426,16 +432,15 @@ kpxcFields.isVisible = function(elem) { // Check CSS visibility const elemStyle = getComputedStyle(elem); - const opacity = Number(elemStyle.opacity); if (elemStyle.visibility && (elemStyle.visibility === 'hidden' || elemStyle.visibility === 'collapse') - || (opacity < MIN_OPACITY || opacity > MAX_OPACITY) + || !isOpacityAllowed(elemStyle.opacity) || parseInt(elemStyle.width, 10) <= MIN_INPUT_FIELD_WIDTH_PX || parseInt(elemStyle.height, 10) <= MIN_INPUT_FIELD_WIDTH_PX) { return false; } // Check for parent opacity - if (kpxcFields.traverseParents(elem, f => f.style.opacity === '0')) { + if (kpxcFields.traverseParents(elem, f => !isOpacityAllowed(f.style.opacity))) { return false; }