Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix(capture): keep blurred field values out of the guide

Luis Ortiza7468b8019d6
diff --git a/src/core/capture/dom/context.ts b/src/core/capture/dom/context.ts
index d98e7f2..3b85119 100644
--- a/src/core/capture/dom/context.ts
+++ b/src/core/capture/dom/context.ts
@@ -1,3 +1,5 @@
+import { isRedactedField } from './element-utils';
+
export interface SiblingElement {
tag: string;
role: string | null;
@@ -81,6 +83,7 @@ function getElementValue(el: Element): string | null {
if (el instanceof HTMLInputElement && (el.type === 'checkbox' || el.type === 'radio'))
return el.checked ? 'checked' : 'unchecked';
if (el instanceof HTMLInputElement && el.type === 'password') return '***';
+ if (isRedactedField(el)) return '***';
if (el instanceof HTMLInputElement && el.value) return `value=${el.value.slice(0, 50)}`;
if (el instanceof HTMLTextAreaElement && el.value) return `value=${el.value.slice(0, 50)}`;
if (el instanceof HTMLSelectElement && el.selectedOptions.length)
diff --git a/src/core/capture/dom/element-utils.ts b/src/core/capture/dom/element-utils.ts
index dace91a..2bce195 100644
--- a/src/core/capture/dom/element-utils.ts
+++ b/src/core/capture/dom/element-utils.ts
@@ -65,6 +65,10 @@ export function isSensitiveField(el: Element | null): boolean {
return el instanceof HTMLInputElement && el.type === 'password';
}
+export function isRedactedField(el: Element | null): boolean {
+ return el instanceof Element && !!el.closest('[data-mimik-blur]');
+}
+
export function eventTarget(e: Event): Element | null {
const inner = e.composedPath?.()[0];
if (inner instanceof Element) return inner;
diff --git a/src/core/capture/events/input-session.ts b/src/core/capture/events/input-session.ts
index 81786f7..fd74764 100644
--- a/src/core/capture/events/input-session.ts
+++ b/src/core/capture/events/input-session.ts
@@ -3,7 +3,7 @@ import { logger } from '@/lib/logger';
import { sendMessage } from '@/lib/messaging';
import { extractDOMContext } from '../dom/context';
import { extractElementMeta, type FrozenRect, freezeRect } from '../dom/element-meta';
-import { getFieldLabel, getFieldValue, isSensitiveField } from '../dom/element-utils';
+import { getFieldLabel, getFieldValue, isRedactedField, isSensitiveField } from '../dom/element-utils';
export class InputSession {
stepId: string | null = null;
@@ -38,8 +38,9 @@ export class InputSession {
if (!this.stepId) return;
this.atEvent = freezeRect(target);
const label = getFieldLabel(target);
- if (isSensitiveField(target)) {
- sendMessage('updateInputStep', { stepId: this.stepId, description: i18n.t('steps.typeSecret') }).catch((err) =>
+ if (isSensitiveField(target) || isRedactedField(target)) {
+ const description = isSensitiveField(target) ? i18n.t('steps.typeSecret') : i18n.t('steps.typeInto', [label]);
+ sendMessage('updateInputStep', { stepId: this.stepId, description }).catch((err) =>
logger.warn('Failed to update input step', err),
);
return;