CSP Fix. fixes #215

This commit is contained in:
Jiiks 2018-08-13 15:13:59 +03:00
parent 45ab822fba
commit d04aa313fc
1 changed files with 2 additions and 0 deletions

View File

@ -257,9 +257,11 @@ export class BetterDiscord {
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
for (let [header, values] of Object.entries(details.responseHeaders)) {
if (!header.match(/^Content-Security-Policy(-Report-Only)?$/i)) continue;
details.responseHeaders[header] = values.map(value => {
const policy = new ContentSecurityPolicy(value);
for (const [key, value] of Object.entries(CSP)) {
if (!policy.get(key)) continue;
policy.add(key, value.join(' '));
}
return policy.toString();