Start on popup

This commit is contained in:
Arlo Breault 2019-05-29 21:27:05 -04:00
parent 11efa42e4c
commit 91255463c6
6 changed files with 87 additions and 16 deletions

View file

@ -11,6 +11,7 @@
"default_icon": {
"32": "icons/status-off.png"
},
"default_title": "Snowflake"
"default_title": "Snowflake",
"default_popup": "popup.html"
}
}

19
proxy/webext/popup.css Normal file
View file

@ -0,0 +1,19 @@
body {
margin: 1em;
}
#active {
padding: 2em;
text-align: center;
}
.learn {
padding-top: 1em;
border-top: 1px solid grey;
}
.learn a {
display: block;
color: grey;
text-decoration: none;
}

17
proxy/webext/popup.html Normal file
View file

@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="popup.css" />
<script src="popup.js"></script>
</head>
<body>
<div id="active">
<img src="icons/status-off.png" />
<p>Offline</p>
</div>
<div class="learn">
<a target="_blank" href="https://snowflake.torproject.org/">Learn more</a>
</div>
</body>
</html>

12
proxy/webext/popup.js Normal file
View file

@ -0,0 +1,12 @@
const port = chrome.runtime.connect({
name: "popup"
});
port.onMessage.addListener((m) => {
const active = m.active;
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";
});