merge: integrate claude/read-repo-YMu21 branch

Merged changes from the other session:
- Ko-fi support link in options footer
- PPI → PII renaming across codebase
- Legal/licensing updates (stronger disclaimer, non-commercial only)
- Custom secret/auto-redact patterns
- Internal refactoring of secret scanner to auto-redact naming
- Custom domains in popup Options tab
- Additional AI services (Perplexity, DeepSeek, HuggingChat, Poe)
- Developer sites (GitHub, GitLab, Reddit, StackOverflow, Pastebin)
- Dynamic content script registration for custom domains

Resolved conflicts in options.html and popup.html (kept newer
"Auto Redact" naming with custom patterns description).

https://claude.ai/code/session_01SWSwDfMVij53bCTNSCLMwn
This commit is contained in:
Claude
2026-03-28 16:39:27 +00:00
14 changed files with 372 additions and 136 deletions
+2 -2
View File
@@ -35,7 +35,7 @@
border-radius: 2px;
}
/* Auto-detect PPI warning banner */
/* Auto-detect PII warning banner */
.ss-autodetect-warning {
position: fixed;
top: 16px;
@@ -136,7 +136,7 @@
font-style: italic;
}
/* Pre-send PPI warning (spellcheck-style, appears while typing) */
/* Pre-send PII warning (spellcheck-style, appears while typing) */
.ss-presend-warning {
position: fixed;
top: 16px;
+47 -36
View File
@@ -287,8 +287,8 @@
}
// ============================================================
// Combined substitution: smart patterns + explicit + secret scan
// + auto-detect warning for unconfigured PPI
// Combined substitution: smart patterns + explicit + auto-redact
// + auto-detect warning for unconfigured PII
// ============================================================
function substituteAll(text) {
const allReplacements = [];
@@ -301,20 +301,20 @@
const explicit = substitute(smart.text, mappings);
allReplacements.push(...explicit.replacements);
// 3. Secret scanner (API keys, tokens, SSNs, credit cards, etc.)
// 3. Auto Redact (API keys, tokens, SSNs, credit cards, custom patterns, etc.)
let finalText = explicit.text;
if (settings.secretScanning !== false) {
const secrets = scanAndRedactSecrets(finalText);
allReplacements.push(...secrets.redactions);
finalText = secrets.text;
if (settings.autoRedact !== false) {
const redacted = runAutoRedact(finalText);
allReplacements.push(...redacted.redactions);
finalText = redacted.text;
}
// 4. Auto-detect: scan the FINAL text for unconfigured PPI
// 4. Auto-detect: scan the FINAL text for unconfigured PII
// Auto-redact if enabled, otherwise just warn
if (settings.autoDetect !== false) {
const warnings = autoDetectPPI(finalText, identity);
const warnings = autoDetectPII(finalText, identity);
if (warnings.length > 0) {
// Auto-redact detected PPI in the outbound text
// Auto-redact detected PII in the outbound text
if (settings.autoRedactDetected !== false) {
for (let i = warnings.length - 1; i >= 0; i--) {
const w = warnings[i];
@@ -343,9 +343,9 @@
}
// ============================================================
// Auto-Detect PPI Scanner (inline for page world)
// Auto-Detect PII Scanner (inline for page world)
// ============================================================
const PPI_PATTERNS = [
const PII_PATTERNS = [
// Network
{ name: 'Private IP', re: /\b(?:10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/g,
hint: 'Private IP address', cat: 'network' },
@@ -574,7 +574,7 @@
});
}
function autoDetectPPI(text, ident) {
function autoDetectPII(text, ident) {
if (!text || text.length < 5) return [];
const hasContext = CONTEXT_WORDS_RE.test(text);
@@ -595,7 +595,7 @@
}
const findings = [];
for (const pat of PPI_PATTERNS) {
for (const pat of PII_PATTERNS) {
if (pat.contextRequired && !hasContext) continue;
pat.re.lastIndex = 0;
let m;
@@ -649,7 +649,7 @@
safeHTML(warningEl, `
<div class="ss-ad-header">
<strong>Silent Send detected potential PPI that may not be substituted:</strong>
<strong>Silent Send detected potential PII that may not be substituted:</strong>
<button class="ss-ad-close">&times;</button>
</div>
${items}
@@ -672,10 +672,11 @@
}
// ============================================================
// Secret Scanner (inline for page world)
// Detects API keys, tokens, passwords, SSNs, credit cards, etc.
// Auto Redact (inline for page world)
// Detects API keys, tokens, passwords, SSNs, credit cards,
// plus user-defined custom patterns from settings.
// ============================================================
const SECRET_PATTERNS = [
const REDACT_PATTERNS = [
// OpenAI
{ name: 'OpenAI Key', re: /\bsk-[A-Za-z0-9]{20,}\b/g, to: '[REDACTED-OPENAI-KEY]' },
{ name: 'OpenAI Project Key', re: /\bsk-proj-[A-Za-z0-9_-]{20,}\b/g, to: '[REDACTED-OPENAI-KEY]' },
@@ -713,11 +714,21 @@
{ name: 'Credit Card', re: /\b(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g, to: '[REDACTED-CARD]' },
];
function scanAndRedactSecrets(text) {
function runAutoRedact(text) {
const redactions = [];
let result = text;
for (const pat of SECRET_PATTERNS) {
// Combine built-in + custom patterns
const allPatterns = [...REDACT_PATTERNS];
const custom = settings.customRedactPatterns || [];
for (const cp of custom) {
if (!cp.enabled || !cp.pattern) continue;
try {
allPatterns.push({ name: cp.name, re: new RegExp(cp.pattern, 'g'), to: cp.redact });
} catch { /* invalid regex — skip */ }
}
for (const pat of allPatterns) {
pat.re.lastIndex = 0;
const matches = [];
let m;
@@ -735,7 +746,7 @@
redactions.push({
original: match.value.slice(0, 8) + '...', // Don't log the full secret
replaced: replacement,
category: 'secret',
category: 'redact',
pattern: pat.name,
});
result =
@@ -1036,7 +1047,7 @@
// ============================================================
// Document Upload Processing
//
// Scans files in FormData uploads for PPI. Supports PDF, DOCX,
// Scans files in FormData uploads for PII. Supports PDF, DOCX,
// XLSX, and text files. Shows preview for binary formats.
// ============================================================
@@ -1108,8 +1119,8 @@
}
/**
* Scan a document file for PPI. Strategy: extract text from any
* format, substitute PPI, upload as plaintext. The AI extracts text
* Scan a document file for PII. Strategy: extract text from any
* format, substitute PII, upload as plaintext. The AI extracts text
* from files anyway — no need to preserve formatting in a file
* the user never gets back. Original stays untouched on disk.
*
@@ -1366,7 +1377,7 @@
safeHTML(docPreviewEl, `
<div class="ss-dp-header">
<strong>PPI found in ${esc(filename)}</strong>
<strong>PII found in ${esc(filename)}</strong>
<span class="ss-dp-count">${preview.replacementCount} item(s)</span>
</div>
<div class="ss-dp-note">${preview.note || ''}</div>
@@ -1495,7 +1506,7 @@
}
}
// Also add auto-detect and secret scanner substitutions from this session
// Also add auto-detect and auto-redact substitutions from this session
for (const [key, entry] of sessionSubstitutions) {
if (!pairs.some(p => p.from.toLowerCase() === key)) {
pairs.push({ from: entry.replaced, to: entry.original });
@@ -1815,7 +1826,7 @@
}
// ============================================================
// Pre-Send PPI Detection — scans as you type/paste (spellcheck style)
// Pre-Send PII Detection — scans as you type/paste (spellcheck style)
// ============================================================
// Generate obviously-fake values using reserved/standard ranges
@@ -1879,7 +1890,7 @@
safeHTML(preSendWarningEl, `
<div class="ss-ad-header">
<strong>Potential PPI detected — not yet configured:</strong>
<strong>Potential PII detected — not yet configured:</strong>
<button class="ss-ad-close">&times;</button>
</div>
${items}
@@ -1918,12 +1929,12 @@
// Persist via storage bridge (handles encryption transparently)
setStorageData('ss_mappings', mappings);
// Replace the PPI value in the current input right now
// Replace the PII value in the current input right now
if (inputEl) {
replaceInInput(inputEl, real, fake);
// Re-scan — will dismiss warning if no more PPI remains
// Re-scan — will dismiss warning if no more PII remains
if (inputScanTimer) clearTimeout(inputScanTimer);
inputScanTimer = setTimeout(() => scanInputForPPI(inputEl), 150);
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
}
// Visual feedback
@@ -1946,7 +1957,7 @@
// Re-scan to update warning
if (inputEl) {
if (inputScanTimer) clearTimeout(inputScanTimer);
inputScanTimer = setTimeout(() => scanInputForPPI(inputEl), 150);
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
}
});
});
@@ -1997,14 +2008,14 @@
// Scan input on type and paste
let inputScanTimer = null;
function scanInputForPPI(target) {
function scanInputForPII(target) {
const text = target.textContent || target.value || '';
if (!text || text.length < 5) {
if (preSendWarningEl) preSendWarningEl.classList.remove('visible');
return;
}
const warnings = autoDetectPPI(text, identity);
const warnings = autoDetectPII(text, identity);
if (warnings.length > 0) {
showPreSendWarning(warnings, target);
} else if (preSendWarningEl) {
@@ -2018,7 +2029,7 @@
if (target.matches?.('[contenteditable], textarea, input[type="text"]')) {
// Debounce — don't scan on every keystroke
if (inputScanTimer) clearTimeout(inputScanTimer);
inputScanTimer = setTimeout(() => scanInputForPPI(target), 800);
inputScanTimer = setTimeout(() => scanInputForPII(target), 800);
}
}, true);
@@ -2028,7 +2039,7 @@
if (target.matches?.('[contenteditable], textarea, input[type="text"]') ||
target.closest?.('[contenteditable]')) {
// Scan shortly after paste completes
setTimeout(() => scanInputForPPI(target.closest?.('[contenteditable]') || target), 200);
setTimeout(() => scanInputForPII(target.closest?.('[contenteditable]') || target), 200);
}
}, true);