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