From a1328e8908aaeb4aebed7f2ba0faed812b3ff886 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sun, 28 Jun 2026 20:16:00 +0200 Subject: [PATCH] use host id instead of host in settings --- src/entrypoints/background/index.ts | 2 +- .../popup/pages/settings/HostsTable.svelte | 2 +- src/lib/host/filemoon.ts | 2 +- src/lib/host/streama2z.ts | 2 +- src/lib/host/voe.ts | 2 +- src/lib/settings.ts | 14 +++++++------- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/entrypoints/background/index.ts b/src/entrypoints/background/index.ts index f469316..43f2f84 100644 --- a/src/entrypoints/background/index.ts +++ b/src/entrypoints/background/index.ts @@ -34,7 +34,7 @@ export default defineBackground(() => { const host = await getHost(new URL(details.url).hostname); if (!host) return; - await HostSettings.addTemporaryHostDomain(host, new URL(details.redirectUrl).hostname); + await HostSettings.addTemporaryHostDomain(host.id, new URL(details.redirectUrl).hostname); }, { urls: [''], types: ['main_frame', 'sub_frame'] } ); diff --git a/src/entrypoints/popup/pages/settings/HostsTable.svelte b/src/entrypoints/popup/pages/settings/HostsTable.svelte index e9e3bb6..44bad7a 100644 --- a/src/entrypoints/popup/pages/settings/HostsTable.svelte +++ b/src/entrypoints/popup/pages/settings/HostsTable.svelte @@ -31,7 +31,7 @@ !disabledHostIds.includes(host.id), - (v) => (v ? HostSettings.removeDisabledHost(host) : HostSettings.addDisabledHost(host)) + (v) => (v ? HostSettings.removeDisabledHost(host.id) : HostSettings.addDisabledHost(host.id)) } size="sm" > diff --git a/src/lib/host/filemoon.ts b/src/lib/host/filemoon.ts index c8da24a..aacd291 100644 --- a/src/lib/host/filemoon.ts +++ b/src/lib/host/filemoon.ts @@ -11,7 +11,7 @@ export default { match: async function (match: RegExpMatchArray) { if (window.location.host.startsWith('filemoon')) { - await HostSettings.addTemporaryHostDomain(this, new URL(match[0]).host); + await HostSettings.addTemporaryHostDomain(this.id, new URL(match[0]).host); return null; } diff --git a/src/lib/host/streama2z.ts b/src/lib/host/streama2z.ts index 270dbc2..c7831ae 100644 --- a/src/lib/host/streama2z.ts +++ b/src/lib/host/streama2z.ts @@ -9,7 +9,7 @@ export default { match: async function (match: RegExpMatchArray) { if (this.domains.indexOf(window.location.hostname) !== -1) { - await HostSettings.addTemporaryHostDomain(this, window.location.hostname); + await HostSettings.addTemporaryHostDomain(this.id, window.location.hostname); return null; } return { diff --git a/src/lib/host/voe.ts b/src/lib/host/voe.ts index 73970d0..9a81d64 100644 --- a/src/lib/host/voe.ts +++ b/src/lib/host/voe.ts @@ -49,7 +49,7 @@ export default { match: async function (match: RegExpMatchArray) { if (window.location.host === 'voe.sx') { - await HostSettings.addTemporaryHostDomain(this, new URL(match[0]).host); + await HostSettings.addTemporaryHostDomain(this.id, new URL(match[0]).host); return null; } else { let json = match[0]; diff --git a/src/lib/settings.ts b/src/lib/settings.ts index 952f24a..81b96c2 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -1,5 +1,5 @@ import { storage } from '#imports'; -import type { Host, HostId } from '@/lib/host'; +import type { HostId } from '@/lib/host'; class Setting { private item; @@ -19,14 +19,14 @@ export class HostSettings { private static disabledHosts = new Setting('local:disabledHosts', []); private static allHostsDisabled = new Setting('local:allHostsDisabled', false); - static addDisabledHost = (host: Host) => + static addDisabledHost = (hostId: HostId) => this.disabledHosts.update((val) => { - if (!val.includes(host.id)) val.push(host.id); + if (!val.includes(hostId)) val.push(hostId); return val; }); - static removeDisabledHost = (host: Host) => + static removeDisabledHost = (hostId: HostId) => this.disabledHosts.update((val) => { - const index = val.indexOf(host.id); + const index = val.indexOf(hostId); if (index !== -1) val.splice(index, 1); return val; }); @@ -38,9 +38,9 @@ export class HostSettings { /* tmp */ private static temporaryHostDomain = new Setting>('local:temporaryHostDomain', {}); - static addTemporaryHostDomain = (host: Host, domain: string) => + static addTemporaryHostDomain = (hostId: HostId, domain: string) => this.temporaryHostDomain.update((val) => { - val[domain] = host.id; + val[domain] = hostId; return val; }); static checkTemporaryHostDomain = (domain: string) => this.temporaryHostDomain.get().then((val) => val[domain]);