From f9a0656d4d9ac47beaef94a5fa5239e9096cfb62 Mon Sep 17 00:00:00 2001 From: bytedream Date: Thu, 4 Aug 2022 17:05:50 +0200 Subject: [PATCH] Optimize redirect functionality --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8edd3e7..d968097 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,20 +4,20 @@ import {Match, matches} from "./match/matches"; async function main() { let match: Match; + let redirect = false; if ((match = await getMatch(window.location.host)) === undefined) { let id: string if ((id = await storageGet('redirect')) !== undefined) { + redirect = true match = matches.find(m => m.id === id) - await storageDelete('redirect') } else { return } } const re = document.body.innerHTML.match(match.regex) - if (re === null) { - return - } + if (re === null) return + if (redirect) await storageDelete('redirect') const url = await match.match(re)