mirror of
https://github.com/hama3254/Crunchyroll-Downloader-v3.0.git
synced 2024-11-15 04:35:06 +01:00
33 lines
954 B
JavaScript
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"]);
|