-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpopup.js
114 lines (93 loc) · 3.37 KB
/
popup.js
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function formatDate(timestamp) {
return new Date(timestamp).toLocaleString();
}
function truncateString(str, length) {
if (str.length <= length) return str;
return str.substring(0, length) + '...';
}
function createFindingCard(finding, url) {
const card = document.createElement('div');
card.className = 'finding-card';
const urlElement = document.createElement('div');
urlElement.className = 'finding-url';
urlElement.textContent = url;
card.appendChild(urlElement);
if (finding.Raw) {
const rawDetail = document.createElement('div');
rawDetail.className = 'finding-detail';
rawDetail.textContent = truncateString(finding.Raw, 200);
card.appendChild(rawDetail);
}
const typeElement = document.createElement('div');
typeElement.className = 'finding-type';
typeElement.textContent = finding.DetectorName || 'Unknown Type';
card.appendChild(typeElement);
const verificationElement = document.createElement('div');
verificationElement.style.padding = '4px 8px';
verificationElement.style.borderRadius = '4px';
verificationElement.style.display = 'inline-block';
verificationElement.style.marginTop = '8px';
verificationElement.style.marginLeft = '8px';
verificationElement.style.fontSize = '12px';
if (finding.Verified) {
verificationElement.style.backgroundColor = '#90EE90';
verificationElement.style.color = '#006400';
verificationElement.textContent = 'Verified';
} else {
verificationElement.style.backgroundColor = '#D3D3D3';
verificationElement.style.color = '#696969';
verificationElement.textContent = 'Unverified';
}
card.appendChild(verificationElement);
return card;
}
function updateQueueStatus(queueSize) {
const queueStatus = document.getElementById('queueStatus');
const queueSizeElement = document.getElementById('queueSize');
queueSizeElement.textContent = `Queue: ${queueSize}`;
if (queueSize > 0) {
queueStatus.classList.add('active');
} else {
queueStatus.classList.remove('active');
}
}
function updateFindings() {
chrome.storage.local.get(null, (items) => {
const findingsList = document.getElementById('findingsList');
findingsList.innerHTML = '';
let totalFindings = 0;
const findings = [];
// Update queue status if available
if ('queueSize' in items) {
updateQueueStatus(items.queueSize);
}
// Collect all findings
Object.entries(items).forEach(([key, value]) => {
if (key.startsWith('findings_')) {
findings.push(...value);
totalFindings += value.length;
}
});
// Update stats
document.getElementById('findingsCount').textContent =
`${totalFindings} secrets found`;
if (findings.length === 0) {
const noFindings = document.createElement('div');
noFindings.className = 'no-findings';
noFindings.textContent = 'No secrets found yet';
findingsList.appendChild(noFindings);
return;
}
// Sort findings by timestamp (newest first)
findings.sort((a, b) => b.timestamp - a.timestamp);
// Create cards for each finding
findings.forEach(finding => {
const card = createFindingCard(finding, finding.url);
findingsList.appendChild(card);
});
});
}
// Update findings when popup opens
document.addEventListener('DOMContentLoaded', updateFindings);
// Listen for changes in storage
chrome.storage.onChanged.addListener(updateFindings);