Merge pull request #76 from outis1one/clDemoe/fix-pii-mapping-persist-5qJzt

Cl demoe/fix pii mapping persist 5q jzt
This commit is contained in:
Outis
2026-04-04 10:22:24 -04:00
committed by GitHub
5 changed files with 53 additions and 21 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Silent Send",
"version": "0.9.44",
"version": "0.9.45",
"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.44",
"version": "0.9.45",
"private": true,
"license": "MIT",
"description": "Browser extension that substitutes personal data before sending to AI services",
+6
View File
@@ -138,6 +138,12 @@ const messageHandlers = {
sendResponse({ mappings });
},
async 'add:mapping'(message, _sender, sendResponse) {
const newMapping = await Storage.addMapping(message.mapping);
const mappings = await Storage.getMappings();
sendResponse({ mapping: newMapping, mappings });
},
async 'get:settings'(_message, _sender, sendResponse) {
const settings = await Storage.getSettings();
sendResponse({ settings });
+25 -19
View File
@@ -1406,21 +1406,17 @@
const fake = decodeURIComponent(btn.dataset.fake);
const cat = btn.dataset.cat || 'general';
// Add to mappings via storage
const result = await getStorageData('ss_mappings');
const currentMappings = result || [];
currentMappings.push({
id: crypto.randomUUID(),
real, substitute: fake,
category: cat,
caseSensitive: false,
enabled: true,
createdAt: Date.now(),
});
await setStorageData('ss_mappings', currentMappings);
// Immediately dismiss this notification item (same as ignore)
btn.closest('.ss-ps-item').remove();
if (!preSendWarningEl.querySelector('.ss-ps-item')) {
preSendWarningEl.classList.remove('visible');
}
// Update local mappings so the fetch interceptor uses them immediately
mappings = currentMappings;
// Add to mappings via background script (handles encryption)
addMappingViaBackground({ real, substitute: fake, category: cat })
.then(updatedMappings => {
if (updatedMappings.length) mappings = updatedMappings;
});
// Replace the PII value in the current input right now
if (inputEl) {
@@ -1429,11 +1425,6 @@
if (inputScanTimer) clearTimeout(inputScanTimer);
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
}
// Visual feedback
btn.textContent = '\u2714';
btn.style.color = '#4ade80';
btn.disabled = true;
});
});
@@ -1493,6 +1484,21 @@
window.postMessage({ type: 'ss:storage-set', key, value }, '*');
}
function addMappingViaBackground(mapping) {
return new Promise(resolve => {
const id = 'ss-add-' + Math.random();
const handler = (event) => {
if (event.data?.type === 'ss:add-mapping-result' && event.data.id === id) {
window.removeEventListener('message', handler);
resolve(event.data.mappings || []);
}
};
window.addEventListener('message', handler);
window.postMessage({ type: 'ss:add-mapping', mapping, id }, '*');
setTimeout(() => { window.removeEventListener('message', handler); resolve([]); }, 2000);
});
}
// Scan input on type and paste
let inputScanTimer = null;
+20
View File
@@ -193,6 +193,26 @@
if (event.data?.type === 'ss:storage-set') {
await api.storage.local.set({ [event.data.key]: event.data.value });
}
if (event.data?.type === 'ss:add-mapping') {
try {
const response = await api.runtime.sendMessage({
type: 'add:mapping',
mapping: event.data.mapping,
});
window.postMessage({
type: 'ss:add-mapping-result',
id: event.data.id,
mappings: response?.mappings || [],
}, '*');
} catch {
window.postMessage({
type: 'ss:add-mapping-result',
id: event.data.id,
mappings: [],
}, '*');
}
}
});
}