VencordWeb: Migrate to manifest v3
This commit is contained in:
parent
e1de6f88fe
commit
a788813383
|
@ -1,24 +0,0 @@
|
||||||
if (typeof browser === "undefined") {
|
|
||||||
var browser = chrome;
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.webRequest.onHeadersReceived.addListener(({ responseHeaders, url }) => {
|
|
||||||
const cspIdx = responseHeaders.findIndex(h => h.name === "content-security-policy");
|
|
||||||
if (cspIdx !== -1)
|
|
||||||
responseHeaders.splice(cspIdx, 1);
|
|
||||||
|
|
||||||
if (url.endsWith(".css")) {
|
|
||||||
const contentType = responseHeaders.find(h => h.name === "content-type");
|
|
||||||
if (contentType)
|
|
||||||
contentType.value = "text/css";
|
|
||||||
else
|
|
||||||
responseHeaders.push({
|
|
||||||
name: "content-type",
|
|
||||||
value: "text/css"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
responseHeaders
|
|
||||||
};
|
|
||||||
}, { urls: ["*://*.discord.com/*"] }, ["blocking", "responseHeaders"]);
|
|
|
@ -1,32 +1,40 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 3,
|
||||||
"name": "Vencord Web",
|
"name": "Vencord Web",
|
||||||
"description": "Yeee",
|
"description": "Yeee",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"author": "Vendicated",
|
"author": "Vendicated",
|
||||||
"homepage_url": "https://github.com/Vendicated/Vencord",
|
"homepage_url": "https://github.com/Vendicated/Vencord",
|
||||||
"background": {
|
|
||||||
"scripts": [
|
"host_permissions": [
|
||||||
"background.js"
|
"*://*.discord.com/*",
|
||||||
]
|
"https://raw.githubusercontent.com/*"
|
||||||
},
|
],
|
||||||
|
|
||||||
|
"permissions": ["declarativeNetRequest"],
|
||||||
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"run_at": "document_start",
|
"run_at": "document_start",
|
||||||
"matches": [
|
"matches": ["*://*.discord.com/*"],
|
||||||
"*://*.discord.com/*"
|
"js": ["content.js"]
|
||||||
],
|
|
||||||
"js": [
|
|
||||||
"content.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"permissions": [
|
|
||||||
"*://*.discord.com/*",
|
|
||||||
"webRequest",
|
|
||||||
"webRequestBlocking"
|
|
||||||
],
|
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
"dist/Vencord.js"
|
{
|
||||||
|
"resources": ["dist/Vencord.js"],
|
||||||
|
"matches": ["*://*.discord.com/*"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"declarative_net_request": {
|
||||||
|
"rule_resources": [
|
||||||
|
{
|
||||||
|
"id": "modifyResponseHeaders",
|
||||||
|
"enabled": true,
|
||||||
|
"path": "modifyResponseHeaders.json"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
38
browser/modifyResponseHeaders.json
Normal file
38
browser/modifyResponseHeaders.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"action": {
|
||||||
|
"type": "modifyHeaders",
|
||||||
|
"responseHeaders": [
|
||||||
|
{
|
||||||
|
"header": "content-security-policy",
|
||||||
|
"operation": "remove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": "content-security-policy-report-only",
|
||||||
|
"operation": "remove"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"resourceTypes": ["main_frame"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"action": {
|
||||||
|
"type": "modifyHeaders",
|
||||||
|
"responseHeaders": [
|
||||||
|
{
|
||||||
|
"header": "content-type",
|
||||||
|
"operation": "set",
|
||||||
|
"value": "text/css"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"resourceTypes": ["stylesheet"],
|
||||||
|
"urlFilter": "https://raw.githubusercontent.com/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -76,7 +76,7 @@ zip({
|
||||||
dist: {
|
dist: {
|
||||||
"Vencord.js": readFileSync("dist/browser.js")
|
"Vencord.js": readFileSync("dist/browser.js")
|
||||||
},
|
},
|
||||||
...Object.fromEntries(await Promise.all(["background.js", "content.js", "manifest.json"].map(async f => [
|
...Object.fromEntries(await Promise.all(["modifyResponseHeaders.json", "content.js", "manifest.json"].map(async f => [
|
||||||
f,
|
f,
|
||||||
await readFile(join("browser", f))
|
await readFile(join("browser", f))
|
||||||
]))),
|
]))),
|
||||||
|
|
Loading…
Reference in a new issue