Merge pull request #74 from outis1one/claude/review-silent-send-gHgCS

Claude/review silent send g hg cs
This commit is contained in:
Outis
2026-04-02 09:28:26 -04:00
committed by GitHub
6 changed files with 80 additions and 71 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Silent Send",
"version": "0.9.42",
"version": "0.9.43",
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
"browser_specific_settings": {
"gecko": {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Silent Send",
"version": "0.9.42",
"version": "0.9.43",
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
"permissions": [
"storage",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "silent-send",
"version": "0.9.42",
"version": "0.9.43",
"private": true,
"license": "MIT",
"description": "Browser extension that substitutes personal data before sending to AI services",
+10 -2
View File
@@ -50,7 +50,7 @@
const sorted = [...maps].sort((a, b) => b.real.length - a.real.length);
for (const m of sorted) {
if (!m.enabled || !m.real || !m.substitute) continue;
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
const escaped = esc(m.real);
const regex = new RegExp(escaped, m.caseSensitive ? 'g' : 'gi');
let match;
@@ -70,7 +70,7 @@
let result = text;
const sorted = [...maps].sort((a, b) => b.substitute.length - a.substitute.length);
for (const m of sorted) {
if (!m.enabled || !m.real || !m.substitute) continue;
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
const escaped = esc(m.substitute);
const regex = new RegExp(escaped, m.caseSensitive ? 'g' : 'gi');
result = result.replace(regex, m.real);
@@ -825,6 +825,8 @@
}
window.__ssInterceptFetch = async function (url, options) {
// Top-level guard: any unhandled error must never break the original request.
try {
if (!settings.enabled || !hasSubstitutions()) {
return originalFetch.call(this, url, options);
}
@@ -886,6 +888,11 @@
}
return originalFetch.call(this, url, options);
} catch (e) {
// Something went wrong in Silent Send — never block the original request
console.warn('[Silent Send] Fetch interceptor error, passing through:', e);
return originalFetch.call(this, url, options);
}
};
// Activate the fetch hook. If early-hook.js ran first (world: MAIN, document_start),
@@ -1130,6 +1137,7 @@
for (const p of pairs) {
const searchTerm = settings.revealMode ? p.to : p.from;
if (!searchTerm?.trim()) continue;
const escaped = esc(searchTerm);
// Add word boundaries when the term starts/ends with word chars to
// prevent partial-word matches (e.g. "aud" inside "Claude")
+4 -4
View File
@@ -21,7 +21,7 @@ const SubstitutionEngine = {
);
for (const mapping of sorted) {
if (!mapping.enabled || !mapping.real || !mapping.substitute) continue;
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
const escaped = this._escapeRegex(mapping.real);
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
@@ -54,7 +54,7 @@ const SubstitutionEngine = {
);
for (const mapping of sorted) {
if (!mapping.enabled || !mapping.real || !mapping.substitute) continue;
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
const escaped = this._escapeRegex(mapping.substitute);
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
@@ -71,7 +71,7 @@ const SubstitutionEngine = {
const found = [];
for (const mapping of mappings) {
if (!mapping.enabled || !mapping.real) continue;
if (!mapping.enabled || !mapping.real?.trim()) continue;
const escaped = this._escapeRegex(mapping.real);
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
@@ -103,7 +103,7 @@ const SubstitutionEngine = {
// Collect all match positions in the original text
const matches = [];
for (const mapping of sorted) {
if (!mapping.enabled || !mapping.real || !mapping.substitute) continue;
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
const escaped = this._escapeRegex(mapping.real);
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
+4 -3
View File
@@ -1814,11 +1814,12 @@ async function applyBulkImport() {
await Storage.updateProfile(profile.id, profile);
}
// Add mappings
// Add mappings — skip any with blank/whitespace-only real values
for (const m of result.mappings) {
if (!m.real?.trim()) continue;
await Storage.addMapping({
real: m.real,
substitute: m.substitute || '',
real: m.real.trim(),
substitute: m.substitute?.trim() || '',
category: m.category || 'general',
caseSensitive: false,
});