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:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Silent Send",
|
"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.",
|
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"storage",
|
"storage",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "silent-send",
|
"name": "silent-send",
|
||||||
"version": "0.9.44",
|
"version": "0.9.45",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Browser extension that substitutes personal data before sending to AI services",
|
"description": "Browser extension that substitutes personal data before sending to AI services",
|
||||||
|
|||||||
@@ -138,6 +138,12 @@ const messageHandlers = {
|
|||||||
sendResponse({ mappings });
|
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) {
|
async 'get:settings'(_message, _sender, sendResponse) {
|
||||||
const settings = await Storage.getSettings();
|
const settings = await Storage.getSettings();
|
||||||
sendResponse({ settings });
|
sendResponse({ settings });
|
||||||
|
|||||||
+25
-19
@@ -1406,21 +1406,17 @@
|
|||||||
const fake = decodeURIComponent(btn.dataset.fake);
|
const fake = decodeURIComponent(btn.dataset.fake);
|
||||||
const cat = btn.dataset.cat || 'general';
|
const cat = btn.dataset.cat || 'general';
|
||||||
|
|
||||||
// Add to mappings via storage
|
// Immediately dismiss this notification item (same as ignore)
|
||||||
const result = await getStorageData('ss_mappings');
|
btn.closest('.ss-ps-item').remove();
|
||||||
const currentMappings = result || [];
|
if (!preSendWarningEl.querySelector('.ss-ps-item')) {
|
||||||
currentMappings.push({
|
preSendWarningEl.classList.remove('visible');
|
||||||
id: crypto.randomUUID(),
|
}
|
||||||
real, substitute: fake,
|
|
||||||
category: cat,
|
|
||||||
caseSensitive: false,
|
|
||||||
enabled: true,
|
|
||||||
createdAt: Date.now(),
|
|
||||||
});
|
|
||||||
await setStorageData('ss_mappings', currentMappings);
|
|
||||||
|
|
||||||
// Update local mappings so the fetch interceptor uses them immediately
|
// Add to mappings via background script (handles encryption)
|
||||||
mappings = currentMappings;
|
addMappingViaBackground({ real, substitute: fake, category: cat })
|
||||||
|
.then(updatedMappings => {
|
||||||
|
if (updatedMappings.length) mappings = updatedMappings;
|
||||||
|
});
|
||||||
|
|
||||||
// Replace the PII value in the current input right now
|
// Replace the PII value in the current input right now
|
||||||
if (inputEl) {
|
if (inputEl) {
|
||||||
@@ -1429,11 +1425,6 @@
|
|||||||
if (inputScanTimer) clearTimeout(inputScanTimer);
|
if (inputScanTimer) clearTimeout(inputScanTimer);
|
||||||
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
|
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 }, '*');
|
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
|
// Scan input on type and paste
|
||||||
let inputScanTimer = null;
|
let inputScanTimer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,26 @@
|
|||||||
if (event.data?.type === 'ss:storage-set') {
|
if (event.data?.type === 'ss:storage-set') {
|
||||||
await api.storage.local.set({ [event.data.key]: event.data.value });
|
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: [],
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user