-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_script.js
More file actions
77 lines (69 loc) · 3.16 KB
/
Copy pathupdate_script.js
File metadata and controls
77 lines (69 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const fs = require('fs');
let code = fs.readFileSync('src/content/index.tsx', 'utf8');
const regex = /overlay\.innerHTML = [\s\S]*? ;/m;
const replacement = const riskScore = Math.min(99, detections.length * 20 + Math.floor(Math.random() * 15) + 50);
const colorMap = [
{ border: 'rgba(239,68,68,0.4)', text: '#fca5a5', bg: 'rgba(239,68,68,0.05)' },
{ border: 'rgba(234,179,8,0.4)', text: '#fcd34d', bg: 'rgba(234,179,8,0.05)' },
{ border: 'rgba(59,130,246,0.4)', text: '#93c5fd', bg: 'rgba(59,130,246,0.05)' },
{ border: 'rgba(16,185,129,0.4)', text: '#6ee7b7', bg: 'rgba(16,185,129,0.05)' }
];
let tagsHtml = "";
detections.slice(0, 4).forEach((d, idx) => {
const c = colorMap[idx % colorMap.length];
let displayValue = d.label.toUpperCase();
if(idx === 0 && d.value && d.label.toLowerCase().includes('file')) {
displayValue = (d.label.toUpperCase() + ": " + escapeHtml(d.value)).slice(0, 40).toUpperCase();
}
tagsHtml += \<div class="sentirx-tag" style="border: 1px solid \; background: \; color: \;">\</div>\;
});
overlay.innerHTML = \
<div class="sentirx-card" style="background: \;">
<div class="sentirx-left">
<div class="sentirx-brand">
<svg viewBox="0 0 24 24"><path fill="currentColor" d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
<span class="sentirx-name">Sentrix AI</span>
</div>
<div class="sentirx-status">
<div class="sentirx-status-dot"></div>
Sensitive data detected
</div>
<div class="sentirx-risk-header">
<span>RISK LEVEL</span>
<span class="sentirx-risk-value">\%</span>
</div>
<div class="sentirx-risk-bar-bg">
<div class="sentirx-risk-bar-fill" style="width: \%"></div>
</div>
</div>
<div class="sentirx-middle">
<div class="sentirx-middle-title">Sensitive data spotted in your prompt</div>
<div class="sentirx-tags">
\
</div>
</div>
<div class="sentirx-actions">
<button class="sentirx-btn sentirx-btn-primary" id="sentirx-redact">
Auto Redact
</button>
<button class="sentirx-btn sentirx-btn-secondary" id="sentirx-edit">
Edit
</button>
<button class="sentirx-btn sentirx-btn-secondary" id="sentirx-ignore">
Send Anyway
</button>
<button class="sentirx-close" id="sentirx-close">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
</div>
\;;
const startIndex = code.indexOf(' overlay.innerHTML = \');
const endIndex = code.indexOf(' shadowRoot.appendChild(overlay);');
if (startIndex !== -1 && endIndex !== -1) {
code = code.substring(0, startIndex) + replacement + "\n" + code.substring(endIndex);
fs.writeFileSync('src/content/index.tsx', code);
console.log("Done");
} else {
console.log("Not found.");
}