mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Reimagine the badge
Trac 27385
This commit is contained in:
parent
0bded511b9
commit
e60f22833a
29 changed files with 401 additions and 351 deletions
38
proxy/webext/embed.js
Normal file
38
proxy/webext/embed.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* global chrome, Popup */
|
||||
|
||||
const port = chrome.runtime.connect({
|
||||
name: "popup"
|
||||
});
|
||||
|
||||
port.onMessage.addListener((m) => {
|
||||
const { active, enabled, total, missingFeature } = m;
|
||||
const popup = new Popup();
|
||||
|
||||
if (missingFeature) {
|
||||
popup.setImgSrc('off');
|
||||
popup.setStatusText("Snowflake is off");
|
||||
popup.setStatusDesc("WebRTC feature is not detected.", 'firebrick');
|
||||
popup.hideButton();
|
||||
return;
|
||||
}
|
||||
|
||||
const clients = active ? 1 : 0;
|
||||
|
||||
if (enabled) {
|
||||
popup.setChecked(true);
|
||||
popup.setToggleText('Turn Off');
|
||||
popup.setStatusText(`${clients} client${(clients !== 1) ? 's' : ''} connected.`);
|
||||
popup.setStatusDesc(`Your snowflake has helped ${total} user${(total !== 1) ? 's' : ''} circumvent censorship in the last 24 hours.`);
|
||||
} else {
|
||||
popup.setChecked(false);
|
||||
popup.setToggleText('Turn On');
|
||||
popup.setStatusText("Snowflake is off");
|
||||
popup.setStatusDesc("");
|
||||
}
|
||||
|
||||
popup.setImgSrc(active ? "running" : enabled ? "on" : "off");
|
||||
});
|
||||
|
||||
document.addEventListener('change', (event) => {
|
||||
port.postMessage({ enabled: event.target.checked });
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue