mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Save webextension toggle state
Save whether the snowflake extension is currently enabled in local storage so that users do not need to opt-in again every time the browser is restarted
This commit is contained in:
parent
e93584029a
commit
2cd69f6f25
2 changed files with 16 additions and 1 deletions
|
@ -59,6 +59,7 @@ class WebExtUI extends UI
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@initStats()
|
@initStats()
|
||||||
|
@initToggle()
|
||||||
chrome.runtime.onConnect.addListener @onConnect
|
chrome.runtime.onConnect.addListener @onConnect
|
||||||
|
|
||||||
initStats: ->
|
initStats: ->
|
||||||
|
@ -69,6 +70,18 @@ class WebExtUI extends UI
|
||||||
@postActive()
|
@postActive()
|
||||||
), 60 * 60 * 1000
|
), 60 * 60 * 1000
|
||||||
|
|
||||||
|
initToggle: ->
|
||||||
|
try
|
||||||
|
getting = chrome.storage.local.get("snowflake-enabled", (result) =>
|
||||||
|
@enabled = result['snowflake-enabled']
|
||||||
|
update()
|
||||||
|
chrome.browserAction.setIcon
|
||||||
|
path:
|
||||||
|
32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
|
||||||
|
)
|
||||||
|
catch
|
||||||
|
log "Toggle state not yet saved"
|
||||||
|
|
||||||
postActive: ->
|
postActive: ->
|
||||||
@port?.postMessage
|
@port?.postMessage
|
||||||
active: @active
|
active: @active
|
||||||
|
@ -90,6 +103,7 @@ class WebExtUI extends UI
|
||||||
path:
|
path:
|
||||||
32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
|
32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
|
||||||
@postActive()
|
@postActive()
|
||||||
|
storing = chrome.storage.local.set({"snowflake-enabled":@enabled}, () -> log "Stored toggle state")
|
||||||
|
|
||||||
onDisconnect: (port) =>
|
onDisconnect: (port) =>
|
||||||
@port = null
|
@port = null
|
||||||
|
|
|
@ -13,5 +13,6 @@
|
||||||
},
|
},
|
||||||
"default_title": "Snowflake",
|
"default_title": "Snowflake",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "popup.html"
|
||||||
}
|
},
|
||||||
|
"permissions": ["storage"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue