mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 13:33:25 +00:00
proof of concept, its theoritically possible for this extension to work
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "index.js"
|
"service_worker": "worker.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
"default_title": "movie-web extension",
|
"default_title": "movie-web extension",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "popup.html"
|
||||||
},
|
},
|
||||||
"permissions": ["storage", "tabs", "cookies", "scripting"],
|
"permissions": ["declarativeNetRequest"],
|
||||||
"host_permissions": ["<all_urls>"],
|
"host_permissions": ["<all_urls>"],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["index.js"]
|
"scripts": ["worker.js"]
|
||||||
},
|
},
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
|
42
src/index.ts
42
src/index.ts
@@ -1,10 +1,36 @@
|
|||||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
chrome.declarativeNetRequest.updateDynamicRules({
|
||||||
(details) => {
|
removeRuleIds: [666],
|
||||||
console.log(details);
|
addRules: [
|
||||||
return { requestHeaders: details.requestHeaders };
|
{
|
||||||
},
|
id: 666,
|
||||||
{ urls: ['<all_urls>'] },
|
priority: 1,
|
||||||
['blocking', 'requestHeaders'],
|
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');
|
console.log('loaded extension');
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { resolve, sep } from 'path'
|
import { resolve, dirname } from 'path'
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import { manifestMerge } from './plugins/manifest';
|
import { manifestMerge } from './plugins/manifest';
|
||||||
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||||
@@ -19,12 +19,13 @@ export default defineConfig({
|
|||||||
viteStaticCopy({
|
viteStaticCopy({
|
||||||
targets: staticAssets.map(file => ({
|
targets: staticAssets.map(file => ({
|
||||||
src: resolve(__dirname, file),
|
src: resolve(__dirname, file),
|
||||||
dest: resolve(__dirname, file.replace(/^src/, 'dist')),
|
dest: dirname(resolve(__dirname, file.replace(/^src/, 'dist'))),
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
root: "src",
|
root: "src",
|
||||||
build: {
|
build: {
|
||||||
|
emptyOutDir: true,
|
||||||
minify: false,
|
minify: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: [{
|
output: [{
|
||||||
|
Reference in New Issue
Block a user