summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2023-02-22 21:15:00 +0100
committerNicholas Tay <nick@windblume.net>2023-02-22 21:18:18 +0100
commitebe23c4d29ece449a8847128300d783714d945f4 (patch)
tree9e6037789ef738081d9cf538bc7c60a363c55c9e
parent9c319b574fff128850e0ebe04d0d95d301bef554 (diff)
downloadcertain-ebe23c4d29ece449a8847128300d783714d945f4.tar.gz
certain-ebe23c4d29ece449a8847128300d783714d945f4.tar.bz2
certain-ebe23c4d29ece449a8847128300d783714d945f4.zip
Update with count of "bad" requests
-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) {