From 1cf4940453d97616fcefb5f46f4587efc64fca88 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sun, 11 Jan 2026 21:17:10 +0100 Subject: [PATCH] minor refactor --- src/entrypoints/content/index.ts | 12 +++++------- src/lib/host/index.ts | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/entrypoints/content/index.ts b/src/entrypoints/content/index.ts index b123a3f..407419f 100644 --- a/src/entrypoints/content/index.ts +++ b/src/entrypoints/content/index.ts @@ -1,4 +1,4 @@ -import { getHost, hosts, type Host, type HostMatch } from '@/lib/host'; +import { getHost, HostMatchType, hosts, type HostMatch } from '@/lib/host'; import { FF2MPVSettings } from '@/lib/settings'; export default defineContentScript({ @@ -13,10 +13,8 @@ export default defineContentScript({ }); async function main() { - let host: Host | null; - if ((host = await getHost(window.location.host)) === null) { - return; - } + const host = await getHost(window.location.host); + if (!host) return; let re = null; for (const regex of host.regex) { @@ -24,7 +22,7 @@ async function main() { break; } } - if (re === null) { + if (!re) { return; } @@ -42,7 +40,7 @@ async function main() { await browser.runtime.sendMessage({ action: 'ff2mpv', url: hostMatch.url }); } - if (host.replace && hostMatch.type != 'hls') { + if (host.replace && hostMatch.type != HostMatchType.HLS) { // this destroys all intervals that may spawn popups or events let intervalId = window.setInterval(() => {}, 0); while (intervalId--) { diff --git a/src/lib/host/index.ts b/src/lib/host/index.ts index 23e6a09..5668c02 100644 --- a/src/lib/host/index.ts +++ b/src/lib/host/index.ts @@ -63,7 +63,7 @@ export const hosts = [ Vupload ]; -export async function getHost(domain: string) { +export async function getHost(domain: string): Promise { if (await HostSettings.getAllHostsDisabled()) return null; const disabledIds = await HostSettings.getDisabledHosts();