Loading proxy/init-webext.coffee +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ init = () -> snowflake = new Snowflake config, ui, broker log '== snowflake proxy ==' update() update = () -> if !ui.enabled Loading proxy/ui.coffee +15 −11 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ All of Snowflake's DOM manipulation and inputs. class UI active: false enabled: false enabled: true setStatus: (msg) -> Loading Loading @@ -73,14 +73,14 @@ class WebExtUI extends UI initToggle: -> try getting = chrome.storage.local.get("snowflake-enabled", (result) => if result['snowflake-enabled'] != undefined @enabled = result['snowflake-enabled'] update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if @enabled then "on" else "off") + ".png" @setEnabled @enabled else log "Toggle state not yet saved" ) catch log "Toggle state not yet saved" log "Error retrieving toggle state" postActive: -> @port?.postMessage Loading @@ -98,10 +98,7 @@ class WebExtUI extends UI onMessage: (m) => @enabled = m.enabled update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if @enabled then "on" else "off") + ".png" @setEnabled @enabled @postActive() storing = chrome.storage.local.set({ "snowflake-enabled": @enabled }, () -> log "Stored toggle state") Loading @@ -117,3 +114,10 @@ class WebExtUI extends UI chrome.browserAction.setIcon path: 32: "icons/status-running.png" setEnabled: (enabled) -> update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if enabled then "on" else "off") + ".png" proxy/webext/manifest.json +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ }, "browser_action": { "default_icon": { "32": "icons/status-off.png" "32": "icons/status-on.png" }, "default_title": "Snowflake", "default_popup": "popup.html" Loading proxy/webext/popup.html +2 −2 Original line number Diff line number Diff line Loading @@ -7,14 +7,14 @@ </head> <body> <div id="active"> <img src="icons/status-off.png" /> <img src="icons/status-on.png" /> <p></p> <p></p> </div> <div class="b toggle"> <label id=toggle>Turn On</label> <label class="switch"> <input id="enabled" type="checkbox"/> <input id="enabled" type="checkbox" checked/> <span class="slider round"></span> </label> </div> Loading proxy/webext/popup.js +1 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ port.onMessage.addListener((m) => { const div = document.getElementById('active'); const img = div.querySelector('img'); const enabled = m.enabled img.src = `icons/status-${enabled ? "on" : "off"}.png`; const ps = div.querySelectorAll('p'); const clients = active ? 1 : 0; const enabledText = document.getElementById('toggle'); Loading @@ -16,15 +15,13 @@ port.onMessage.addListener((m) => { enabledText.innerText = 'Turn Off'; 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.`; if (active) { img.src = `icons/status-running.png`; } } else { ps[0].innerText = "Snowflake is off"; ps[1].innerText = ""; document.getElementById('enabled').checked = false; enabledText.innerText = 'Turn On'; } img.src = `icons/status-${active? "running" : enabled? "on" : "off"}.png`; }); document.addEventListener('change', (event) => { Loading Loading
proxy/init-webext.coffee +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ init = () -> snowflake = new Snowflake config, ui, broker log '== snowflake proxy ==' update() update = () -> if !ui.enabled Loading
proxy/ui.coffee +15 −11 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ All of Snowflake's DOM manipulation and inputs. class UI active: false enabled: false enabled: true setStatus: (msg) -> Loading Loading @@ -73,14 +73,14 @@ class WebExtUI extends UI initToggle: -> try getting = chrome.storage.local.get("snowflake-enabled", (result) => if result['snowflake-enabled'] != undefined @enabled = result['snowflake-enabled'] update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if @enabled then "on" else "off") + ".png" @setEnabled @enabled else log "Toggle state not yet saved" ) catch log "Toggle state not yet saved" log "Error retrieving toggle state" postActive: -> @port?.postMessage Loading @@ -98,10 +98,7 @@ class WebExtUI extends UI onMessage: (m) => @enabled = m.enabled update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if @enabled then "on" else "off") + ".png" @setEnabled @enabled @postActive() storing = chrome.storage.local.set({ "snowflake-enabled": @enabled }, () -> log "Stored toggle state") Loading @@ -117,3 +114,10 @@ class WebExtUI extends UI chrome.browserAction.setIcon path: 32: "icons/status-running.png" setEnabled: (enabled) -> update() chrome.browserAction.setIcon path: 32: "icons/status-" + (if enabled then "on" else "off") + ".png"
proxy/webext/manifest.json +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ }, "browser_action": { "default_icon": { "32": "icons/status-off.png" "32": "icons/status-on.png" }, "default_title": "Snowflake", "default_popup": "popup.html" Loading
proxy/webext/popup.html +2 −2 Original line number Diff line number Diff line Loading @@ -7,14 +7,14 @@ </head> <body> <div id="active"> <img src="icons/status-off.png" /> <img src="icons/status-on.png" /> <p></p> <p></p> </div> <div class="b toggle"> <label id=toggle>Turn On</label> <label class="switch"> <input id="enabled" type="checkbox"/> <input id="enabled" type="checkbox" checked/> <span class="slider round"></span> </label> </div> Loading
proxy/webext/popup.js +1 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ port.onMessage.addListener((m) => { const div = document.getElementById('active'); const img = div.querySelector('img'); const enabled = m.enabled img.src = `icons/status-${enabled ? "on" : "off"}.png`; const ps = div.querySelectorAll('p'); const clients = active ? 1 : 0; const enabledText = document.getElementById('toggle'); Loading @@ -16,15 +15,13 @@ port.onMessage.addListener((m) => { enabledText.innerText = 'Turn Off'; 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.`; if (active) { img.src = `icons/status-running.png`; } } else { ps[0].innerText = "Snowflake is off"; ps[1].innerText = ""; document.getElementById('enabled').checked = false; enabledText.innerText = 'Turn On'; } img.src = `icons/status-${active? "running" : enabled? "on" : "off"}.png`; }); document.addEventListener('change', (event) => { Loading