Count the number of clients the webext has served

This commit is contained in:
Arlo Breault 2019-06-19 16:02:12 -04:00
parent 91255463c6
commit 85625e19f9
4 changed files with 21 additions and 3 deletions

View file

@ -5,6 +5,7 @@ body {
#active {
padding: 2em;
text-align: center;
min-width: 128px;
}
.learn {

View file

@ -8,7 +8,8 @@
<body>
<div id="active">
<img src="icons/status-off.png" />
<p>Offline</p>
<p></p>
<p></p>
</div>
<div class="learn">
<a target="_blank" href="https://snowflake.torproject.org/">Learn more</a>

View file

@ -7,6 +7,8 @@ port.onMessage.addListener((m) => {
const div = document.getElementById('active');
const img = div.querySelector('img');
img.src = `icons/status-${active ? "on" : "off"}.png`;
const p = div.querySelector('p');
p.innerText = active ? "Connected" : "Offline";
const ps = div.querySelectorAll('p');
const clients = active ? 1 : 0;
ps[0].innerText = `${clients} client${(clients !== 1) ? 's' : ''} connected.`;
ps[1].innerText = `Your snowflake has helped ${m.total} user${(m.total !== 1) ? 's' : ''} circumvent censorship in the last 24 hours.`;
});