Skip to content

Commit 00b54be

Browse files
committed
Draw SSL icons in the background.
Previously, the icons could be selected with a transparent highlight, now they can't be selected at all.
1 parent 0fd3d6a commit 00b54be

File tree

2 files changed

+46
-31
lines changed

2 files changed

+46
-31
lines changed

src/popup.html

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,32 @@
4545
tr {
4646
height: 21px;
4747
}
48-
img {
49-
user-select: none;
50-
}
51-
img::selection {
52-
background-color: transparent;
53-
}
5448
.mainRow {
5549
font-weight: bold;
5650
}
57-
.sslImg {
58-
padding-right: 6pt;
51+
/* Draw SSL icon in the background, for the "zeroth" column. */
52+
.domainTd::before {
53+
content: "";
54+
position: absolute;
55+
left: 4px;
56+
top: 50%;
57+
transform: translateY(-50%);
58+
width: 15px;
59+
height: 11px;
60+
background-image: var(--ssl-icon);
61+
}
62+
/* Tooltip for the "zeroth" column, left of the fake vertical line. */
63+
.sslTooltip {
64+
position: absolute;
65+
left: 0;
66+
top: 0;
67+
width: 23px;
68+
height: 100%;
5969
}
6070
.domainTd {
6171
user-select: text;
72+
position: relative;
73+
padding-left: 27px;
6274
}
6375
.addrTd {
6476
font-family: monospace;
@@ -140,7 +152,7 @@
140152
background-color: #222;
141153
color: #eee;
142154
}
143-
.sslImg {
155+
.domainTd::before {
144156
filter: invert(1);
145157
}
146158
.snipImg {

src/popup.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ window.onload = async function() {
4343
const TEST_TUPLES = [
4444
["ipv6.example.com", "2001:db8::f00", "6", DFLAG_SSL],
4545
["ipv4.example.com", "192.0.2.9", "4", DFLAG_NOSSL],
46-
["cached.example.com", "2001:db8::f00", "6", DFLAG_SSL | DFLAG_NOSSL | AFLAG_CACHE],
46+
["cached.looooooooooooooooo000ooooooongname.example.com", "2001:db8::f00", "6", DFLAG_SSL | DFLAG_NOSSL | AFLAG_CACHE],
4747
];
4848
pushAll(TEST_TUPLES, "646", REGULAR_COLOR, 0);
4949
}
@@ -231,24 +231,6 @@ function makeImg(src, title) {
231231
return img;
232232
}
233233

234-
function makeSslImg(flags) {
235-
switch (flags & (DFLAG_SSL | DFLAG_NOSSL)) {
236-
case DFLAG_SSL | DFLAG_NOSSL:
237-
return makeImg(
238-
"gray_schrodingers_lock.png",
239-
"Mixture of HTTPS and non-HTTPS connections.");
240-
case DFLAG_SSL:
241-
return makeImg(
242-
"gray_lock.png",
243-
"Connection uses HTTPS.\n" +
244-
"Warning: IPvFoo does not verify the integrity of encryption.");
245-
default:
246-
return makeImg(
247-
"gray_unlock.png",
248-
"Connection does not use HTTPS.");
249-
}
250-
}
251-
252234
function makeRow(isFirst, tuple) {
253235
const domain = tuple[0];
254236
const addr = tuple[1];
@@ -261,12 +243,33 @@ function makeRow(isFirst, tuple) {
261243
}
262244

263245
// Build the SSL icon for the "zeroth" pseudo-column.
264-
const sslImg = makeSslImg(flags);
265-
sslImg.className = "sslImg";
246+
let sslIcon = "";
247+
let sslTitle = "";
248+
switch (flags & (DFLAG_SSL | DFLAG_NOSSL)) {
249+
case DFLAG_SSL | DFLAG_NOSSL:
250+
sslIcon = "gray_schrodingers_lock.png";
251+
sslTitle = "Mixture of HTTPS and non-HTTPS connections.";
252+
break;
253+
case DFLAG_SSL:
254+
sslIcon = "gray_lock.png";
255+
sslTitle = "Connection uses HTTPS.\nWarning: IPvFoo does not verify the integrity of encryption.";
256+
break;
257+
default:
258+
sslIcon = "gray_unlock.png";
259+
sslTitle = "Connection does not use HTTPS.";
260+
break;
261+
}
266262

267263
// Build the "Domain" column.
268264
const domainTd = document.createElement("td");
269-
domainTd.appendChild(sslImg);
265+
domainTd.style.setProperty("--ssl-icon", `url("${sslIcon}")`);
266+
267+
// Tooltip for the "zeroth" column.
268+
const sslTooltip = document.createElement("span");
269+
sslTooltip.className = "sslTooltip";
270+
sslTooltip.title = sslTitle;
271+
domainTd.appendChild(sslTooltip);
272+
270273
if (domain.length > LONG_DOMAIN) {
271274
domainTd.appendChild(makeSnippedText(domain, Math.floor(LONG_DOMAIN / 2)));
272275
} else {

0 commit comments

Comments
 (0)