1 Commits

Author SHA1 Message Date
William Oldham
6a3d32dcc3 Merge pull request #9 from movie-web/dev
Extension v1.0.2
2024-01-25 21:39:15 +00:00
2 changed files with 2 additions and 17 deletions

View File

@@ -1,13 +0,0 @@
import { isChrome } from '~utils/extension';
// Both brave and firefox for some reason need this extension reload,
// If this isn't done, they will never load properly and will fail updateDynamicRules()
if (isChrome()) {
chrome.runtime.onStartup.addListener(() => {
chrome.runtime.reload();
});
} else {
browser.runtime.onStartup.addListener(() => {
browser.runtime.reload();
});
}

View File

@@ -49,20 +49,19 @@ const mapBodyToFetchBody = (body: Request['body'], bodyType: Request['bodyType']
const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (req, res) => {
try {
const url = makeFullUrl(req.body.url, req.body);
await assertDomainWhitelist(req.sender.tab.url);
if (req.body.headers['User-Agent']) {
await setDynamicRules({
ruleId: MAKE_REQUEST_DYNAMIC_RULE,
targetDomains: [new URL(url).hostname],
targetDomains: [new URL(req.body.url).hostname],
requestHeaders: {
'User-Agent': req.body.headers['User-Agent'],
},
});
}
const response = await fetch(url, {
const response = await fetch(makeFullUrl(req.body.url, req.body), {
method: req.body.method,
headers: req.body.headers,
body: mapBodyToFetchBody(req.body.body, req.body.bodyType),
@@ -81,7 +80,6 @@ const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (r
},
});
} catch (err) {
console.error('failed request', err);
res.send({
success: false,
error: err.message,