diff options
-rw-r--r-- | background.js | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/background.js b/background.js index 59c6c2b..0df541a 100644 --- a/background.js +++ b/background.js @@ -43,23 +43,25 @@ function setIcon(icon) { browser.browserAction.setIcon({ path: "icons/" + icon + ".png" }); } -function onReady() { - // Listen for all header receive events, which contain the cert details we want - browser.webRequest.onHeadersReceived.addListener( - onHeaderReceive, - { - urls: ["<all_urls>"] - }, - [ - "blocking" - ] - ); -} +// Listen for all header receive events, which contain the cert details we want +browser.webRequest.onHeadersReceived.addListener( + onHeaderReceive, + { + urls: ["<all_urls>"] + }, + [ + "blocking" + ] +); -// Fetch config for certs list -const getting = browser.storage.sync.get("certs"); -getting.then(saved => { - certs = saved.certs; - console.log("certs=" + certs) - onReady(); -}, console.error);
\ No newline at end of file +function updateCerts() { + const getting = browser.storage.sync.get("certs"); + getting.then(saved => { + certs = saved.certs; + console.log("certs=" + certs) + }, console.error) +} +// Listen to config change for certs list +browser.storage.local.onChanged.addListener(() => updateCerts()); +// Initial config fetch +updateCerts();
\ No newline at end of file |