Skip to content

Commit dab935a

Browse files
committed
Remove requests count in extension icon
1 parent ebe549d commit dab935a

1 file changed

Lines changed: 0 additions & 53 deletions

File tree

  • browser-extensions/chrome/src/background

browser-extensions/chrome/src/background/index.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ interface TabConnection {
1717
const tabConnections = new Map<number, TabConnection>();
1818
const devtoolsPageConnections = new Map<number, chrome.runtime.Port>();
1919
const spooshDetectedTabs = new Set<number>();
20-
const tabTraceCounts = new Map<number, number>();
21-
const tabBaselineCounts = new Map<number, number>();
2220

2321
function updateIcon(tabId: number) {
2422
if (!chrome.action) return;
@@ -43,25 +41,6 @@ function updateIcon(tabId: number) {
4341
});
4442
}
4543

46-
function updateBadgeCount(tabId: number, count: number) {
47-
if (!chrome.action) return;
48-
49-
tabTraceCounts.set(tabId, count);
50-
51-
const text = count > 0 ? (count > 99 ? "99+" : String(count)) : "";
52-
chrome.action.setBadgeText({ tabId, text });
53-
chrome.action.setBadgeBackgroundColor({ tabId, color: "#ef4444" });
54-
chrome.action.setBadgeTextColor({ tabId, color: "#ffffff" });
55-
}
56-
57-
function clearBadgeCount(tabId: number) {
58-
tabTraceCounts.delete(tabId);
59-
60-
if (chrome.action) {
61-
chrome.action.setBadgeText({ tabId, text: "" });
62-
}
63-
}
64-
6544
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
6645
if (message?.type === "GET_DETECTION_STATUS" && message.tabId) {
6746
sendResponse({ detected: spooshDetectedTabs.has(message.tabId) });
@@ -86,27 +65,6 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
8665
} else if (pageMessage.type === "SPOOSH_NOT_DETECTED") {
8766
spooshDetectedTabs.delete(tabId);
8867
updateIcon(tabId);
89-
clearBadgeCount(tabId);
90-
} else if (
91-
pageMessage.type === "FULL_SYNC" ||
92-
pageMessage.type === "COUNT_UPDATED"
93-
) {
94-
const payload = pageMessage.payload as { totalTraceCount?: number };
95-
const totalCount = payload?.totalTraceCount ?? 0;
96-
tabTraceCounts.set(tabId, totalCount);
97-
98-
if (!tabConnections.has(tabId)) {
99-
const baseline = tabBaselineCounts.get(tabId) ?? 0;
100-
const newCount = Math.max(0, totalCount - baseline);
101-
updateBadgeCount(tabId, newCount);
102-
}
103-
} else if (pageMessage.type === "TRACES_CLEARED") {
104-
tabTraceCounts.set(tabId, 0);
105-
tabBaselineCounts.set(tabId, 0);
106-
107-
if (!tabConnections.has(tabId)) {
108-
updateBadgeCount(tabId, 0);
109-
}
11068
}
11169

11270
const connection = tabConnections.get(tabId);
@@ -150,8 +108,6 @@ chrome.runtime.onConnect.addListener((port) => {
150108
if (message.type === "INIT" && message.tabId) {
151109
tabId = message.tabId;
152110
tabConnections.set(tabId, { port, tabId });
153-
tabBaselineCounts.delete(tabId);
154-
clearBadgeCount(tabId);
155111

156112
const isAlreadyDetected = spooshDetectedTabs.has(tabId);
157113

@@ -187,19 +143,12 @@ chrome.runtime.onConnect.addListener((port) => {
187143
port.onDisconnect.addListener(() => {
188144
if (tabId) {
189145
tabConnections.delete(tabId);
190-
191-
const currentCount = tabTraceCounts.get(tabId) ?? 0;
192-
tabBaselineCounts.set(tabId, currentCount);
193-
clearBadgeCount(tabId);
194146
}
195147
});
196148
});
197149

198150
chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
199151
if (changeInfo.status === "complete") {
200-
tabBaselineCounts.delete(tabId);
201-
clearBadgeCount(tabId);
202-
203152
chrome.tabs
204153
.sendMessage(tabId, {
205154
source: EXTENSION_MESSAGE_SOURCE,
@@ -216,8 +165,6 @@ chrome.tabs.onRemoved.addListener((tabId) => {
216165
spooshDetectedTabs.delete(tabId);
217166
tabConnections.delete(tabId);
218167
devtoolsPageConnections.delete(tabId);
219-
tabTraceCounts.delete(tabId);
220-
tabBaselineCounts.delete(tabId);
221168
});
222169

223170
chrome.commands.onCommand.addListener((command, tab) => {

0 commit comments

Comments
 (0)