diff --git a/src/tabs/PermissionGrant.tsx b/src/tabs/PermissionGrant.tsx index a8c238c..a2d0047 100644 --- a/src/tabs/PermissionGrant.tsx +++ b/src/tabs/PermissionGrant.tsx @@ -1,3 +1,5 @@ +import React from 'react'; + import { Button } from '~components/Button'; import { usePermission } from '~hooks/usePermission'; import { makeUrlIntoDomain } from '~utils/domains'; @@ -8,11 +10,27 @@ export default function PermissionGrant() { const { grantPermission } = usePermission(); const queryParams = new URLSearchParams(window.location.search); - const redirectUrl = queryParams.get('redirectUrl') ?? 'https://mw.lonelil.ru'; - const domain = makeUrlIntoDomain(redirectUrl); + const redirectUrl = queryParams.get('redirectUrl') ?? undefined; + const domain = redirectUrl ? makeUrlIntoDomain(redirectUrl) : undefined; + + if (!domain) { + return ( +
+
+
+

Permission

+

+ No domain found to grant permission to. +

+
+
+
+ ); + } const redirectBack = () => { chrome.tabs.getCurrent((tab) => { + if (!tab?.id) return; chrome.tabs.update(tab.id, { url: redirectUrl }); }); };