use host id instead of host in settings

This commit is contained in:
2026-06-28 20:20:37 +02:00
parent 0455b53992
commit a1328e8908
6 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -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: ['<all_urls>'], types: ['main_frame', 'sub_frame'] }
);
@@ -31,7 +31,7 @@
<Toggle
bind:checked={
() => !disabledHostIds.includes(host.id),
(v) => (v ? HostSettings.removeDisabledHost(host) : HostSettings.addDisabledHost(host))
(v) => (v ? HostSettings.removeDisabledHost(host.id) : HostSettings.addDisabledHost(host.id))
}
size="sm"
></Toggle>
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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];
+7 -7
View File
@@ -1,5 +1,5 @@
import { storage } from '#imports';
import type { Host, HostId } from '@/lib/host';
import type { HostId } from '@/lib/host';
class Setting<T> {
private item;
@@ -19,14 +19,14 @@ export class HostSettings {
private static disabledHosts = new Setting<HostId[]>('local:disabledHosts', []);
private static allHostsDisabled = new Setting<boolean>('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<Record<string, string>>('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]);