diff --git a/src/main.ts b/src/main.ts index f89f41a..78cea8a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,9 @@ +// Polyfill to prevent "chrome is not defined" errors +// Some dependencies may check for Chrome extension APIs without proper existence checks +if (typeof (globalThis as any).chrome === 'undefined') { + (globalThis as any).chrome = {}; +} + import Services from './services/service'; import { Router } from './router/index'; import './components/header/Header'; diff --git a/src/services/database.service.ts b/src/services/database.service.ts index a9df19b..61ddb05 100755 --- a/src/services/database.service.ts +++ b/src/services/database.service.ts @@ -148,7 +148,7 @@ export class Database { if (this.serviceWorkerCheckIntervalId) clearInterval(this.serviceWorkerCheckIntervalId); - this.serviceWorkerCheckIntervalId = window.setInterval(async () => { + this.serviceWorkerCheckIntervalId = setInterval(async () => { const activeWorker = this.serviceWorkerRegistration?.active || (await this.waitForServiceWorkerActivation( @@ -159,7 +159,7 @@ export class Database { if (payload && payload.length != 0) { activeWorker?.postMessage({ type: "SCAN", payload }); } - }, 5000); + }, 5000) as unknown as number; } catch (error) { console.error("[Database] Service Worker error:", error); } diff --git a/src/workers/core.worker.ts b/src/workers/core.worker.ts index 0405eb2..e638243 100644 --- a/src/workers/core.worker.ts +++ b/src/workers/core.worker.ts @@ -1,3 +1,8 @@ +// Polyfill to prevent "chrome is not defined" errors in worker context +if (typeof (globalThis as any).chrome === 'undefined') { + (globalThis as any).chrome = {}; +} + import * as Comlink from "comlink"; import { ApiReturn, diff --git a/src/workers/network.worker.ts b/src/workers/network.worker.ts index d576930..0f5eaab 100644 --- a/src/workers/network.worker.ts +++ b/src/workers/network.worker.ts @@ -1,3 +1,8 @@ +// Polyfill to prevent "chrome is not defined" errors in worker context +if (typeof (globalThis as any).chrome === 'undefined') { + (globalThis as any).chrome = {}; +} + import * as Comlink from 'comlink'; import { APP_CONFIG } from '../config/constants';