mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 14:43:24 +00:00
Compare commits
11 Commits
1.1.2
...
ec7d9c1237
Author | SHA1 | Date | |
---|---|---|---|
|
ec7d9c1237 | ||
|
bb61fef30a | ||
|
8e179e4455 | ||
|
327f175241 | ||
|
c72ec41228 | ||
|
0bd1a39b53 | ||
|
de0a1b3849 | ||
|
8ba0544468 | ||
|
a884c785f0 | ||
|
0801f64e1b | ||
|
8735f7b4b2 |
4
.github/workflows/deploying.yml
vendored
4
.github/workflows/deploying.yml
vendored
@@ -94,8 +94,8 @@ jobs:
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./chrome/chrome-mv3-prod.zip
|
||||
asset_name: extension-mw.chrome.crx
|
||||
asset_content_type: application/x-chrome-extension
|
||||
asset_name: extension-mw.chrome.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Upload Firefox release
|
||||
uses: actions/upload-release-asset@v1
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@movie-web/extension",
|
||||
"displayName": "movie-web extension",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "Enhance your movie-web experience with just one click",
|
||||
"author": "movie-web",
|
||||
"scripts": {
|
||||
|
@@ -14,6 +14,8 @@ type Response = BaseResponse<{
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (req, res) => {
|
||||
try {
|
||||
if (!req.sender?.tab?.url) throw new Error('No tab URL found in the request.');
|
||||
|
||||
const version = getVersion();
|
||||
res.send({
|
||||
success: true,
|
||||
@@ -24,7 +26,7 @@ const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (re
|
||||
} catch (err) {
|
||||
res.send({
|
||||
success: false,
|
||||
error: err.message,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -32,7 +32,7 @@ type Response<T> = BaseResponse<{
|
||||
const mapBodyToFetchBody = (body: Request['body'], bodyType: Request['bodyType']): BodyInit => {
|
||||
if (bodyType === 'FormData') {
|
||||
const formData = new FormData();
|
||||
body.forEach(([key, value]) => {
|
||||
body.forEach(([key, value]: [any, any]) => {
|
||||
formData.append(key, value.toString());
|
||||
});
|
||||
}
|
||||
@@ -50,6 +50,9 @@ const mapBodyToFetchBody = (body: Request['body'], bodyType: Request['bodyType']
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (req, res) => {
|
||||
try {
|
||||
if (!req.sender?.tab?.url) throw new Error('No tab URL found in the request.');
|
||||
if (!req.body) throw new Error('No request body found in the request.');
|
||||
|
||||
const url = makeFullUrl(req.body.url, req.body);
|
||||
await assertDomainWhitelist(req.sender.tab.url);
|
||||
|
||||
@@ -91,7 +94,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (r
|
||||
console.error('failed request', err);
|
||||
res.send({
|
||||
success: false,
|
||||
error: err.message,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -11,6 +11,9 @@ type Request = BaseRequest & {
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (req, res) => {
|
||||
try {
|
||||
if (!req.sender?.tab?.id) throw new Error('No tab ID found in the request.');
|
||||
if (!req.body) throw new Error('No body found in the request.');
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set('redirectUrl', req.body.redirectUrl);
|
||||
const url = (chrome || browser).runtime.getURL(`/tabs/${req.body.page}.html?${searchParams.toString()}`);
|
||||
@@ -29,7 +32,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (re
|
||||
} catch (err) {
|
||||
res.send({
|
||||
success: false,
|
||||
error: err.message,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -15,6 +15,9 @@ interface Request extends BaseRequest {
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (req, res) => {
|
||||
try {
|
||||
if (!req.sender?.tab?.url) throw new Error('No tab URL found in the request.');
|
||||
if (!req.body) throw new Error('No request body found in the request.');
|
||||
|
||||
await assertDomainWhitelist(req.sender.tab.url);
|
||||
await setDynamicRules(req.body);
|
||||
res.send({
|
||||
@@ -23,7 +26,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (re
|
||||
} catch (err) {
|
||||
res.send({
|
||||
success: false,
|
||||
error: err.message,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -15,5 +15,5 @@ export function useDomain(): null | string {
|
||||
};
|
||||
}, []);
|
||||
|
||||
return makeUrlIntoDomain(domain);
|
||||
return domain ? makeUrlIntoDomain(domain) : null;
|
||||
}
|
||||
|
@@ -8,12 +8,12 @@ export function useDomainWhitelist() {
|
||||
|
||||
const removeDomain = useCallback((domain: string | null) => {
|
||||
if (!domain) return;
|
||||
setDomainWhitelist((s) => [...s.filter((v) => v !== domain)]);
|
||||
setDomainWhitelist((s) => [...(s ?? []).filter((v) => v !== domain)]);
|
||||
}, []);
|
||||
|
||||
const addDomain = useCallback((domain: string | null) => {
|
||||
if (!domain) return;
|
||||
setDomainWhitelist((s) => [...s.filter((v) => v !== domain), domain]);
|
||||
setDomainWhitelist((s) => [...(s ?? []).filter((v) => v !== domain), domain]);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
|
@@ -13,7 +13,7 @@ body {
|
||||
#__plasmo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
background-color: #0A0A10;
|
||||
}
|
||||
|
||||
|
@@ -8,11 +8,27 @@ export default function PermissionGrant() {
|
||||
const { grantPermission } = usePermission();
|
||||
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
const redirectUrl = queryParams.get('redirectUrl') ?? 'https://mw.lonelil.ru';
|
||||
const domain = makeUrlIntoDomain(redirectUrl);
|
||||
const redirectUrl = queryParams.get('redirectUrl') ?? undefined;
|
||||
const domain = redirectUrl ? makeUrlIntoDomain(redirectUrl) : undefined;
|
||||
|
||||
if (!domain) {
|
||||
return (
|
||||
<div className="permission-grant container">
|
||||
<div className="inner-container">
|
||||
<div className="permission-card">
|
||||
<h1 className="color-white">Permission</h1>
|
||||
<p className="text-color" style={{ textAlign: 'center' }}>
|
||||
No domain found to grant permission to.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const redirectBack = () => {
|
||||
chrome.tabs.getCurrent((tab) => {
|
||||
if (!tab?.id) return;
|
||||
chrome.tabs.update(tab.id, { url: redirectUrl });
|
||||
});
|
||||
};
|
||||
|
@@ -123,5 +123,6 @@ export const removeDynamicRules = async (ruleIds: number[]) => {
|
||||
await (chrome || browser).declarativeNetRequest.updateDynamicRules({
|
||||
removeRuleIds: ruleIds,
|
||||
});
|
||||
if ((chrome || browser).runtime.lastError?.message) throw new Error((chrome || browser).runtime.lastError.message);
|
||||
if ((chrome || browser).runtime.lastError?.message)
|
||||
throw new Error((chrome || browser).runtime.lastError?.message ?? 'Unknown error');
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { isChrome } from './extension';
|
||||
|
||||
export function queryCurrentDomain(cb: (domain: string | null) => void) {
|
||||
const handle = (tabUrl: string | null) => {
|
||||
const handle = (tabUrl: string | undefined) => {
|
||||
if (!tabUrl) cb(null);
|
||||
else cb(tabUrl);
|
||||
};
|
||||
|
@@ -1,18 +1,13 @@
|
||||
{
|
||||
"extends": "plasmo/templates/tsconfig.base",
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
".plasmo/index.d.ts",
|
||||
"./**/*.ts",
|
||||
"./**/*.tsx"
|
||||
],
|
||||
"exclude": ["node_modules"],
|
||||
"include": [".plasmo/index.d.ts", "./**/*.ts", "./**/*.tsx"],
|
||||
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"paths": {
|
||||
"~*": [
|
||||
"./src/*"
|
||||
]
|
||||
"~*": ["./src/*"]
|
||||
},
|
||||
"baseUrl": "."
|
||||
}
|
||||
|
Reference in New Issue
Block a user