mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 18:13:25 +00:00
Initial plasmo setup
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 637 B |
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"background": {
|
||||
"service_worker": "worker.js"
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "movie-web extension",
|
||||
"version": "0.1",
|
||||
"description": "Allows for sources to work without a proxy",
|
||||
"icons": {
|
||||
"16": "assets/icons/16.png"
|
||||
},
|
||||
"action": {
|
||||
"default_title": "movie-web extension",
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"permissions": ["declarativeNetRequest"],
|
||||
"host_permissions": ["<all_urls>"],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["*.js.map"],
|
||||
"matches": ["<all_urls>"]
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"background": {
|
||||
"scripts": ["worker.js"]
|
||||
},
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "extension-firefox@movie-web.app"
|
||||
}
|
||||
}
|
||||
}
|
24
src/background/messages/proxy.ts
Normal file
24
src/background/messages/proxy.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { PlasmoMessaging } from '@plasmohq/messaging';
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
|
||||
try {
|
||||
const response = await fetch(req.body.url, {
|
||||
headers: req.body.headers,
|
||||
});
|
||||
const body = await response.text();
|
||||
|
||||
res.send({
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
requestHeaders: req.body.headers,
|
||||
responseHeaders: Object.fromEntries(response.headers.entries()),
|
||||
body,
|
||||
});
|
||||
} catch (err) {
|
||||
res.send({
|
||||
error: err.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default handler;
|
11
src/contents/movie-web.ts
Normal file
11
src/contents/movie-web.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { PlasmoCSConfig } from 'plasmo';
|
||||
|
||||
import { relayMessage } from '@plasmohq/messaging';
|
||||
|
||||
export const config: PlasmoCSConfig = {
|
||||
matches: ['https://movie-web.app/*', 'https://dev.movie-web.app/*', 'http://localhost:5173/*'],
|
||||
};
|
||||
|
||||
relayMessage({
|
||||
name: 'proxy',
|
||||
});
|
36
src/index.ts
36
src/index.ts
@@ -1,36 +0,0 @@
|
||||
chrome.declarativeNetRequest.updateDynamicRules({
|
||||
removeRuleIds: [666],
|
||||
addRules: [
|
||||
{
|
||||
id: 666,
|
||||
priority: 1,
|
||||
condition: {
|
||||
initiatorDomains: ['movie-web.app'],
|
||||
},
|
||||
action: {
|
||||
type: chrome.declarativeNetRequest.RuleActionType.MODIFY_HEADERS,
|
||||
requestHeaders: [
|
||||
{
|
||||
header: 'X-Test',
|
||||
operation: chrome.declarativeNetRequest.HeaderOperation.SET,
|
||||
value: 'Hello world',
|
||||
},
|
||||
],
|
||||
responseHeaders: [
|
||||
{
|
||||
header: 'Access-Control-Allow-Origin',
|
||||
operation: chrome.declarativeNetRequest.HeaderOperation.SET,
|
||||
value: '*',
|
||||
},
|
||||
{
|
||||
header: 'Access-Control-Allow-Methods',
|
||||
operation: chrome.declarativeNetRequest.HeaderOperation.SET,
|
||||
value: 'POST,GET,OPTIONS,PUT',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
console.log('loaded extension');
|
@@ -1,10 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>movie-web extension</title>
|
||||
<link rel="stylesheet" href="./popup/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="./popup/index.ts"></script>
|
||||
<h1>This is the popup</h1>
|
||||
</body>
|
||||
</html>
|
11
src/popup.tsx
Normal file
11
src/popup.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
function IndexPopup() {
|
||||
return (
|
||||
<div style={{ width: 180 }}>
|
||||
<p>
|
||||
Extension running at version {chrome.runtime.getManifest().version}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default IndexPopup
|
@@ -1 +0,0 @@
|
||||
console.log('popup js');
|
@@ -1,3 +0,0 @@
|
||||
.test {
|
||||
color: blue
|
||||
}
|
Reference in New Issue
Block a user