summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--background.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/background.js b/background.js
index 5295d9f..4d94e69 100644
--- a/background.js
+++ b/background.js
@@ -23,7 +23,7 @@ async function certInspectUpdate(requestId, tabId) {
);
if (securityInfo.state !== "secure" || securityInfo.isUntrusted) {
- setIcon("nope", tabId);
+ await tabInsecure(tabId);
return;
}
@@ -34,12 +34,27 @@ async function certInspectUpdate(requestId, tabId) {
for (let cert of certs) {
if (rootCA.subject.includes(cert)) {
- setIcon("nope", tabId);
+ await tabInsecure(tabId);
return;
}
}
- setIcon("ok", tabId);
+ await tabProbablySecure(tabId);
+}
+
+async function tabProbablySecure(tabId) {
+ // only update if not already insecure
+ let t = await browser.browserAction.getBadgeText({ tabId });
+ if (t === "")
+ setIcon("ok", tabId);
+}
+
+async function tabInsecure(tabId) {
+ let t = await browser.browserAction.getBadgeText({ tabId });
+ if (!t)
+ setIcon("nope", tabId);
+ let n = Number(t) + 1;
+ browser.browserAction.setBadgeText({ text: n.toString(), tabId });
}
function setIcon(icon, tabId) {