Repository navigation
Expand file tree
/
Copy pathcontent.js
More file actions
53 lines (50 loc) · 1.61 KB
/
Copy pathcontent.js
File metadata and controls
53 lines (50 loc) · 1.61 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
const tooltip = document.createElement("div");
tooltip.id = "knight-tooltip";
tooltip.style.cssText = `
position: fixed;
background: #111;
border: 1px solid #333;
border-radius: 10px;
padding: 12px 16px;
font-size: 13px;
font-family: system-ui;
color: #f0f0f0;
z-index: 999999;
pointer-events: auto;
display: none;
box-shadow: 0 8px 30px rgba(0,0,0,0.8);
width: 240px;
line-height: 1.5;
`;
document.body.appendChild(tooltip);
//tooltip on hover
document.addEventListener("mouseover", function(e) {
const link = e.target.closest("a");
if (!link || !link.href) return;
tooltip.style.left = e.clientX + 15 + "px";
tooltip.style.top = e.clientY + 15 + "px";
try {
chrome.runtime.sendMessage({ action: "isBlacklisted", url: link.href }, function(response) {
if (chrome.runtime.lastError) return;
if (!response) return;
const dangerous = response.result;
tooltip.innerHTML = dangerous
? `<span style="color:#ff4444">🔴 Dangerous</span><br><small style="color:#888">Knight has flagged this domain</small>`
: `<span style="color:#44ff88">✅ Safe</span><br><small style="color:#888">Not in threat database</small>`;
tooltip.style.borderColor = dangerous ? "#ff0000" : "#333";
tooltip.style.display = "block";
});
} catch(e) {
return;
}
});
//tooltip on mouse Leave
document.addEventListener("mouseout", function(e) {
const link = e.target.closest("a");
if (!link) return;
if (tooltip.contains(e.relatedTarget)) return;
tooltip.style.display = "none";
});
document.addEventListener("scroll", function() {
tooltip.style.display = "none";
});