mirror of
https://github.com/bytedream/stream-bypass.git
synced 2026-02-04 05:16:27 +01:00
minor refactor
This commit is contained in:
@@ -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';
|
import { FF2MPVSettings } from '@/lib/settings';
|
||||||
|
|
||||||
export default defineContentScript({
|
export default defineContentScript({
|
||||||
@@ -13,10 +13,8 @@ export default defineContentScript({
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
let host: Host | null;
|
const host = await getHost(window.location.host);
|
||||||
if ((host = await getHost(window.location.host)) === null) {
|
if (!host) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let re = null;
|
let re = null;
|
||||||
for (const regex of host.regex) {
|
for (const regex of host.regex) {
|
||||||
@@ -24,7 +22,7 @@ async function main() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (re === null) {
|
if (!re) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +40,7 @@ async function main() {
|
|||||||
await browser.runtime.sendMessage({ action: 'ff2mpv', url: hostMatch.url });
|
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
|
// this destroys all intervals that may spawn popups or events
|
||||||
let intervalId = window.setInterval(() => {}, 0);
|
let intervalId = window.setInterval(() => {}, 0);
|
||||||
while (intervalId--) {
|
while (intervalId--) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export const hosts = [
|
|||||||
Vupload
|
Vupload
|
||||||
];
|
];
|
||||||
|
|
||||||
export async function getHost(domain: string) {
|
export async function getHost(domain: string): Promise<Host | null> {
|
||||||
if (await HostSettings.getAllHostsDisabled()) return null;
|
if (await HostSettings.getAllHostsDisabled()) return null;
|
||||||
|
|
||||||
const disabledIds = await HostSettings.getDisabledHosts();
|
const disabledIds = await HostSettings.getDisabledHosts();
|
||||||
|
|||||||
Reference in New Issue
Block a user