-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
43 lines (39 loc) · 1.81 KB
/
log.js
File metadata and controls
43 lines (39 loc) · 1.81 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
document.addEventListener('DOMContentLoaded', () => {
const tableBody = document.getElementById('log-table-body');
const lifetimeCounterSpan = document.getElementById('lifetime-counter');
chrome.storage.local.get({ lifetimeCveCount: 0 }, (data) => {
if (lifetimeCounterSpan) {
lifetimeCounterSpan.textContent = data.lifetimeCveCount.toLocaleString('en-US');
}
});
chrome.storage.local.get({ cveApiLog: [] }, (data) => {
const log = data.cveApiLog;
if (log.length === 0) {
const row = tableBody.insertRow();
const cell = row.insertCell();
cell.colSpan = 4;
cell.textContent = 'No log entries found.';
cell.style.textAlign = 'center';
return;
}
log.forEach(entry => {
const row = tableBody.insertRow();
row.insertCell().textContent = new Date(entry.timestamp).toLocaleString('en-US', {
year: '2-digit', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit'
});
row.insertCell().textContent = entry.cve;
const statusCell = row.insertCell();
statusCell.textContent = entry.status;
statusCell.className = entry.status.toLowerCase() === 'success' ? 'status-success' : 'status-failed';
const detailsCell = row.insertCell();
const pre = document.createElement('pre');
let detailsText = `Method: ${entry.details.method || 'N/A'}\nURL: ${entry.details.url || 'N/A'}`;
if (entry.details.error) {
detailsText += `\nError: ${entry.details.error}`;
}
pre.textContent = detailsText;
detailsCell.appendChild(pre);
});
});
});