mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 15:53:24 +00:00
Remove requestDomain from messaging
This commit is contained in:
@@ -17,7 +17,7 @@ const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (re
|
||||
res.send({
|
||||
success: true,
|
||||
version,
|
||||
allowed: await isDomainWhitelisted(req.body.requestDomain),
|
||||
allowed: await isDomainWhitelisted(req.sender.tab.url),
|
||||
});
|
||||
} catch (err) {
|
||||
res.send({
|
||||
|
@@ -26,7 +26,7 @@ type Response<T> = BaseResponse<{
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (req, res) => {
|
||||
try {
|
||||
await assertDomainWhitelist(req.body.requestDomain);
|
||||
await assertDomainWhitelist(req.sender.tab.url);
|
||||
|
||||
const response = await fetch(makeFullUrl(req.body.url, req.body), {
|
||||
method: req.body.method,
|
||||
|
@@ -24,7 +24,7 @@ const mapHeadersToDeclarativeNetRequestHeaders = (
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (req, res) => {
|
||||
try {
|
||||
await assertDomainWhitelist(req.body.requestDomain);
|
||||
await assertDomainWhitelist(req.sender.tab.url);
|
||||
|
||||
if (chrome) {
|
||||
await chrome.declarativeNetRequest.updateDynamicRules({
|
||||
|
@@ -1,3 +1 @@
|
||||
export interface BaseRequest {
|
||||
requestDomain: string;
|
||||
}
|
||||
export interface BaseRequest {}
|
||||
|
@@ -16,7 +16,8 @@ export function useDomainStorage() {
|
||||
return useStorage<string[]>('domainWhitelist', (v) => v ?? DEFAULT_DOMAIN_WHITELIST);
|
||||
}
|
||||
|
||||
export const isDomainWhitelisted = async (url: string) => {
|
||||
export const isDomainWhitelisted = async (url: string | undefined) => {
|
||||
if (!url) return false;
|
||||
const domain = makeUrlIntoDomain(url);
|
||||
if (!domain) return false;
|
||||
return domainIsInWhitelist(domain);
|
||||
|
Reference in New Issue
Block a user