5 Commits

Author SHA1 Message Date
William Oldham
a2eef13d28 Merge pull request #24 from movie-web/dev
Version 1.1.2
2024-03-05 21:08:35 +00:00
William Oldham
01a03cfeb8 Merge pull request #19 from movie-web/dev
Version 1.1.1 - Apply CORS header rules to all requests regardless of MW set headers
2024-02-21 18:57:54 +00:00
mrjvs
d989fd1ee8 Merge pull request #16 from movie-web/dev
Version 1.1 - Headers and Permissions update
2024-02-10 21:10:47 +01:00
mrjvs
2ea2208dea Merge pull request #11 from movie-web/dev
Extension v1.0.3
2024-01-31 20:08:34 +01:00
William Oldham
6a3d32dcc3 Merge pull request #9 from movie-web/dev
Extension v1.0.2
2024-01-25 21:39:15 +00:00
15 changed files with 30 additions and 57 deletions

View File

@@ -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.zip
asset_content_type: application/zip
asset_name: extension-mw.chrome.crx
asset_content_type: application/x-chrome-extension
- name: Upload Firefox release
uses: actions/upload-release-asset@v1

View File

@@ -1,7 +1,7 @@
{
"name": "@movie-web/extension",
"displayName": "movie-web extension",
"version": "1.1.4",
"version": "1.1.2",
"description": "Enhance your movie-web experience with just one click",
"author": "movie-web",
"scripts": {

View File

@@ -14,8 +14,6 @@ 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,
@@ -26,7 +24,7 @@ const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (re
} catch (err) {
res.send({
success: false,
error: err instanceof Error ? err.message : String(err),
error: err.message,
});
}
};

View File

@@ -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]: [any, any]) => {
body.forEach(([key, value]) => {
formData.append(key, value.toString());
});
}
@@ -50,9 +50,6 @@ 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);
@@ -94,7 +91,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, Response<any>> = async (r
console.error('failed request', err);
res.send({
success: false,
error: err instanceof Error ? err.message : String(err),
error: err.message,
});
}
};

View File

@@ -11,9 +11,6 @@ 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()}`);
@@ -32,7 +29,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (re
} catch (err) {
res.send({
success: false,
error: err instanceof Error ? err.message : String(err),
error: err.message,
});
}
};

View File

@@ -15,9 +15,6 @@ 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({
@@ -26,7 +23,7 @@ const handler: PlasmoMessaging.MessageHandler<Request, BaseResponse> = async (re
} catch (err) {
res.send({
success: false,
error: err instanceof Error ? err.message : String(err),
error: err.message,
});
}
};

View File

@@ -15,5 +15,5 @@ export function useDomain(): null | string {
};
}, []);
return domain ? makeUrlIntoDomain(domain) : null;
return makeUrlIntoDomain(domain);
}

View File

@@ -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 {
@@ -23,9 +23,9 @@ export function useDomainWhitelist() {
};
}
export function useToggleWhitelistDomain(domain: string | null) {
export function useToggleWhitelistDomain(domain: string) {
const { domainWhitelist, addDomain, removeDomain } = useDomainWhitelist();
const isWhitelisted = domainWhitelist.includes(domain ?? '');
const isWhitelisted = domainWhitelist.includes(domain);
const { grantPermission } = usePermission();
const iconPath = (chrome || browser).runtime.getURL(isWhitelisted ? 'assets/active.png' : 'assets/inactive.png');

View File

@@ -28,7 +28,7 @@ function IndexPopup() {
) : (
<Frame>
<div className="popup">
{page === 'toggle' && domain ? <ToggleButton active={isWhitelisted} onClick={toggle} domain={domain} /> : null}
{page === 'toggle' ? <ToggleButton active={isWhitelisted} onClick={toggle} domain={domain} /> : null}
{page === 'disabled' ? <DisabledScreen /> : null}
<BottomLabel />
</div>

View File

@@ -13,7 +13,7 @@ body {
#__plasmo {
display: flex;
flex-direction: column;
height: 100%;
min-height: 100%;
background-color: #0A0A10;
}

View File

@@ -8,27 +8,11 @@ export default function PermissionGrant() {
const { grantPermission } = usePermission();
const queryParams = new URLSearchParams(window.location.search);
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 redirectUrl = queryParams.get('redirectUrl') ?? 'https://mw.lonelil.ru';
const domain = makeUrlIntoDomain(redirectUrl);
const redirectBack = () => {
chrome.tabs.getCurrent((tab) => {
if (!tab?.id) return;
chrome.tabs.update(tab.id, { url: redirectUrl });
});
};

View File

@@ -10,10 +10,6 @@ body {
padding-bottom: 50px;
}
#__plasmo {
height: unset;
}
.permission-request.container {
width: 90%;
margin: 100px auto;

View File

@@ -123,6 +123,5 @@ 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 ?? 'Unknown error');
if ((chrome || browser).runtime.lastError?.message) throw new Error((chrome || browser).runtime.lastError.message);
};

View File

@@ -1,7 +1,7 @@
import { isChrome } from './extension';
export function queryCurrentDomain(cb: (domain: string | null) => void) {
const handle = (tabUrl: string | undefined) => {
const handle = (tabUrl: string | null) => {
if (!tabUrl) cb(null);
else cb(tabUrl);
};

View File

@@ -1,13 +1,18 @@
{
"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": "."
}