summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2023-02-22 21:08:18 +0100
committerNicholas Tay <nick@windblume.net>2023-02-22 21:08:18 +0100
commit9c319b574fff128850e0ebe04d0d95d301bef554 (patch)
tree661b3c42a2913e36f01187fe1e66fa24d86c49bb
parent93e082dfa376f4ca63628a9a0eb70a8a83a88592 (diff)
downloadcertain-9c319b574fff128850e0ebe04d0d95d301bef554.tar.gz
certain-9c319b574fff128850e0ebe04d0d95d301bef554.tar.bz2
certain-9c319b574fff128850e0ebe04d0d95d301bef554.zip
Set icon only for relevant tab id
-rw-r--r--background.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/background.js b/background.js
index 0df541a..5295d9f 100644
--- a/background.js
+++ b/background.js
@@ -4,14 +4,17 @@ let certs = [];
// On header receive, inspect cert and update app icon as required
async function onHeaderReceive(details) {
+ if (details.tabId < 0) // tabId < 0 means non-user tab
+ return;
+
try {
- await certInspectUpdate(details.requestId);
+ await certInspectUpdate(details.requestId, details.tabId);
} catch(error) {
console.error(error);
}
}
-async function certInspectUpdate(requestId) {
+async function certInspectUpdate(requestId, tabId) {
let securityInfo = await browser.webRequest.getSecurityInfo(
requestId,
{
@@ -20,7 +23,7 @@ async function certInspectUpdate(requestId) {
);
if (securityInfo.state !== "secure" || securityInfo.isUntrusted) {
- setIcon("nope");
+ setIcon("nope", tabId);
return;
}
@@ -31,16 +34,19 @@ async function certInspectUpdate(requestId) {
for (let cert of certs) {
if (rootCA.subject.includes(cert)) {
- setIcon("nope");
+ setIcon("nope", tabId);
return;
}
}
- setIcon("ok");
+ setIcon("ok", tabId);
}
-function setIcon(icon) {
- browser.browserAction.setIcon({ path: "icons/" + icon + ".png" });
+function setIcon(icon, tabId) {
+ browser.browserAction.setIcon({
+ path: "icons/" + icon + ".png",
+ tabId: tabId
+ });
}
// Listen for all header receive events, which contain the cert details we want