From 85942e5827d29fbbb3eeca7d12b50297c7a4f0a2 Mon Sep 17 00:00:00 2001 From: skidoodle Date: Sat, 7 Mar 2026 00:54:08 +0100 Subject: [PATCH] call stuff --- entrypoints/background.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/entrypoints/background.ts b/entrypoints/background.ts index cac4d62..ec29190 100644 --- a/entrypoints/background.ts +++ b/entrypoints/background.ts @@ -164,6 +164,32 @@ async function updateState(tabId: number, updates: Partial, expectedUr export default defineBackground({ main() { + browser.runtime.onStartup.addListener(() => { + StorageService.cleanExpiredGeoCache().catch(console.error); + }); + + browser.runtime.onInstalled.addListener(() => { + StorageService.cleanExpiredGeoCache().catch(console.error); + }); + + browser.alarms.create('cleanup-geo-cache', { periodInMinutes: 1440 }); + browser.alarms.onAlarm.addListener((alarm) => { + if (alarm.name === 'cleanup-geo-cache') { + StorageService.cleanExpiredGeoCache().catch(console.error); + } + }); + + browser.tabs.onReplaced.addListener((addedTabId, removedTabId) => { + tabStates.delete(removedTabId); + StorageService.removeTabState(removedTabId); + + browser.tabs.get(addedTabId).then((tab) => { + if (tab.url) { + initTab(tab.id!, tab.url, true) + } + }).catch(() => { }) + }) + browser.webNavigation.onBeforeNavigate.addListener((details) => { if (details.frameId !== 0) return; initTab(details.tabId, details.url, false);