π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
feat: blur CSS styles and regex PII patterns
Luis Ortiz922fbaa80217
diff --git a/src/core/blur/regexes.ts b/src/core/blur/regexes.tsnew file mode 100644index 0000000..65455d8--- /dev/null+++ b/src/core/blur/regexes.ts@@ -0,0 +1,47 @@+export type PresetKey = 'email' | 'phone' | 'ssn' | 'creditCard' | 'ipAddress' | 'macAddress';++export const PRESET_REGEXES: Record<PresetKey, RegExp> = {+ email: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,+ ssn: /\b\d{3}-?\d{2}-?\d{4}\b/g,+ creditCard: /\b(?:\d[ -]*?){13,19}\b/g,+ phone: /(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{2,4}\)?[\s.-]?)?\d{3,4}[\s.-]?\d{4}\b/g,+ ipAddress: /\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g,+ macAddress: /\b[0-9A-F]{2}(?:[:-][0-9A-F]{2}){5}\b/gi,+};++export const PRESET_LABELS: Record<PresetKey, string> = {+ email: 'Email',+ phone: 'Phone Numbers',+ ssn: 'SSN',+ creditCard: 'Credit Card',+ ipAddress: 'IP Address',+ macAddress: 'MAC Address',+};++export interface MatchRange {+ start: number;+ end: number;+}++export function findMatches(text: string, patterns: RegExp[]): MatchRange[] {+ const ranges: MatchRange[] = [];+ for (const pattern of patterns) {+ pattern.lastIndex = 0;+ let match = pattern.exec(text);+ while (match !== null) {+ ranges.push({ start: match.index, end: match.index + match[0].length });+ match = pattern.exec(text);+ }+ }+ ranges.sort((a, b) => a.start - b.start);+ const merged: MatchRange[] = [];+ for (const range of ranges) {+ const last = merged[merged.length - 1];+ if (last && range.start <= last.end) {+ last.end = Math.max(last.end, range.end);+ } else {+ merged.push({ ...range });+ }+ }+ return merged;+}diff --git a/src/core/blur/styles.ts b/src/core/blur/styles.tsnew file mode 100644index 0000000..acafb6b--- /dev/null+++ b/src/core/blur/styles.ts@@ -0,0 +1,26 @@+const STYLE_ID = 'mimik-blur-style';+const BLUR_PX = 10;++export function injectBlurStyles() {+ if (document.getElementById(STYLE_ID)) return;+ const style = document.createElement('style');+ style.id = STYLE_ID;+ style.textContent = `+ .mimik-blur {+ filter: blur(${BLUR_PX}px);+ transition: filter 120ms ease;+ }+ .mimik-blur.mimik-blur-peek {+ filter: none;+ }+ .mimik-manual-blur {+ filter: blur(${BLUR_PX}px);+ transition: filter 120ms ease;+ }+ `;+ document.head.appendChild(style);+}++export function removeBlurStyles() {+ document.getElementById(STYLE_ID)?.remove();+}