styleViaXhr: allow cookies for sandbox CSP

This commit is contained in:
tophf 2020-11-15 00:50:08 +03:00
parent 1b8091afb7
commit be41f13ef3

View File

@ -78,6 +78,13 @@ CHROME && (async () => {
name: 'Set-Cookie',
value: `${chrome.runtime.id}=${prefs.get('disableAll') ? 1 : 0}${blobId}`,
});
// allow cookies for sandbox CSP (known case: raw github urls)
for (const h of responseHeaders) {
if (h.name.toLowerCase() === 'content-security-policy' && h.value.includes('sandbox')) {
h.value = h.value.replace(/((^|;)\s*sandbox)(\s+[^;]+)?\s*(?=;|$)/, '$1 allow-same-origin');
break;
}
}
return {responseHeaders};
}
}