add permission page

This commit is contained in:
Jorrin
2024-01-14 18:18:21 +01:00
parent 854e4361ee
commit 8189fa4819
6 changed files with 224 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import type { PlasmoMessaging } from '@plasmohq/messaging';
import { hasPermission } from '~hooks/usePermission';
import { getVersion } from '~hooks/useVersion';
import type { BaseRequest } from '~types/request';
import type { BaseResponse } from '~types/response';
@@ -8,16 +9,17 @@ import { isDomainWhitelisted } from '~utils/storage';
type Response = BaseResponse<{
version: string;
allowed: boolean;
hasPermission: boolean;
}>;
const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (req, res) => {
try {
const version = getVersion();
res.send({
success: true,
version,
allowed: await isDomainWhitelisted(req.sender.tab.url),
hasPermission: await hasPermission(),
});
} catch (err) {
res.send({