Crunchyroll-Downloader-v3.0/CRD-addon/background.js
hama3254 9f6cdbb705 port config and default subtitles added
port config and default subtitles added
2021-02-20 18:25:49 +01:00

33 lines
954 B
JavaScript

browser.webRequest.onHeadersReceived.addListener(
details => {
browser.test.log(`onHeadersReceived ${JSON.stringify(details)}\n`);
if (!details.fromCache) {
//console.log("not cached");
browser.test.sendMessage("statusCode", details.statusCode);
const mime = details.responseHeaders.find(header => {
return header.value && header.name === "Server";
});
if (mime) {
//console.log(mime.value);
browser.runtime.sendMessage({
Server: mime.value
});
} else {
details.responseHeaders.push({
name: "Content-Security-Policy",
value: "upgrade-insecure-requests",
});
}
return {
responseHeaders: details.responseHeaders,
};
} else {
console.log("cached");
}
}, {
urls: ["http://127.0.0.1/*"],
},
["blocking", "responseHeaders"]);