import { useDomainWhitelist } from '~hooks/useDomainWhitelist'; import { usePermission } from '~hooks/usePermission'; import { makeUrlIntoDomain } from '~utils/domains'; import './PermissionGrant.css'; export default function PermissionGrant() { const { domainWhitelist } = useDomainWhitelist(); const { hasPermission, grantPermission } = usePermission(); const queryParams = new URLSearchParams(window.location.search); const redirectUrl = queryParams.get('redirectUrl') ?? 'https://movie-web.app'; const domain = makeUrlIntoDomain(redirectUrl); const permissionsGranted = domainWhitelist.includes(domain) && hasPermission; const redirectBack = () => { chrome.tabs.getCurrent((tab) => { chrome.tabs.update(tab.id, { url: redirectUrl }); }); }; const handleGrantPermission = () => { grantPermission(domain).then(() => { redirectBack(); }); }; return (

Permission

Websites need to ask for permission
before they can use this extension

The website {domain} wants to
use the extension on their page.

); }