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": {
|
||||
"service_worker": "index.js"
|
||||
"service_worker": "worker.js"
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
"default_title": "movie-web extension",
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"permissions": ["storage", "tabs", "cookies", "scripting"],
|
||||
"permissions": ["declarativeNetRequest"],
|
||||
"host_permissions": ["<all_urls>"],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"background": {
|
||||
"scripts": ["index.js"]
|
||||
"scripts": ["worker.js"]
|
||||
},
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
|
42
src/index.ts
42
src/index.ts
@@ -1,10 +1,36 @@
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
(details) => {
|
||||
console.log(details);
|
||||
return { requestHeaders: details.requestHeaders };
|
||||
},
|
||||
{ urls: ['<all_urls>'] },
|
||||
['blocking', 'requestHeaders'],
|
||||
);
|
||||
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,4 +1,4 @@
|
||||
import { resolve, sep } from 'path'
|
||||
import { resolve, dirname } from 'path'
|
||||
import { defineConfig } from 'vite'
|
||||
import { manifestMerge } from './plugins/manifest';
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||
@@ -19,12 +19,13 @@ export default defineConfig({
|
||||
viteStaticCopy({
|
||||
targets: staticAssets.map(file => ({
|
||||
src: resolve(__dirname, file),
|
||||
dest: resolve(__dirname, file.replace(/^src/, 'dist')),
|
||||
dest: dirname(resolve(__dirname, file.replace(/^src/, 'dist'))),
|
||||
}))
|
||||
})
|
||||
],
|
||||
root: "src",
|
||||
build: {
|
||||
emptyOutDir: true,
|
||||
minify: false,
|
||||
rollupOptions: {
|
||||
output: [{
|
||||
|
Reference in New Issue
Block a user