-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathextension.DBC.js
executable file
·48 lines (42 loc) · 1.58 KB
/
extension.DBC.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var dbcloginurl = "chriseric1.github.io"
var extraInfoSpecRequest = ["blocking", "requestHeaders"];
var extraInfoSpecResponse = ["blocking", "responseHeaders"];
if (typeof chrome !== "undefined") {
if (typeof browser !== "undefined") {
var fir = true;
var chr = false;
} else {
var fir = false;
var chr = true;
}
}
if (chr) extraInfoSpecRequest.push("extraHeaders") && extraInfoSpecResponse.push("extraHeaders");
chrome.webRequest.onBeforeSendHeaders.addListener(
function (details) {
if (chr) if (!details.initiator.includes(dbcloginurl)) return;
if (fir) if (!details.originUrl.includes(dbcloginurl)) return;
let header = details.requestHeaders.find((e) => e.name.toLowerCase() === "origin");
if (header) header.value = "https://discord.com";
else details.requestHeaders.push({ name: "Origin", value: "https://discord.com" });
details.requestHeaders = details.requestHeaders.filter((x) => x.name.toLowerCase() !== "user-agent");
return { requestHeaders: details.requestHeaders };
},
{
urls: ["<all_urls>"],
},
extraInfoSpecRequest
);
chrome.webRequest.onHeadersReceived.addListener(
(details) => {
if (chr) if (!details.initiator.includes(dbcloginurl)) return;
if (fir) if (!details.originUrl.includes(dbcloginurl)) return;
let header = details.responseHeaders.find((e) => e.name.toLowerCase() === "access-control-allow-origin");
if (header) header.value = "*";
else details.responseHeaders.push({ name: "Access-Control-Allow-Origin", value: "*" });
return { responseHeaders: details.responseHeaders };
},
{
urls: ["<all_urls>"],
},
extraInfoSpecResponse
);