-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
30 lines (27 loc) · 1020 Bytes
/
background.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
var RegisteredFixes = {
"set-cookie": [
function RemovePartitioned(value) { // Remove experimental feature https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
var didModify = false;
value = value.replace(/(?<=;)\s*Partitioned;?/, () => { didModify = true; return ""; });
return didModify ? value : null;
}
]
};
chrome.webRequest.onHeadersReceived.addListener(function ({ responseHeaders }) {
var wasModified = false;
for (var i = 0; i < responseHeaders.length; i++) {
var header = responseHeaders[i];
if (!header.value)
continue;
var headerFixes = RegisteredFixes[header.name.toLowerCase()];
if (headerFixes) {
for (var j = 0; j < headerFixes.length; j++) {
var fix = headerFixes[j](header.value);
if (fix === null) continue;
header.value = fix;
wasModified = true;
}
}
}
return wasModified ? { responseHeaders } : {};
}, { urls: ["<all_urls>"] }, ["responseHeaders", "blocking", "extraHeaders"]);