diff --git a/sources/code/main/modules/csp.ts b/sources/code/main/modules/csp.ts index cbe25a11..a9c74039 100644 --- a/sources/code/main/modules/csp.ts +++ b/sources/code/main/modules/csp.ts @@ -195,6 +195,10 @@ export function getWebCordCSP(additionalPolicies: CSP[]|[] = []) { type cspFilter = (value:CSP|undefined) => value is CSP; if(cache && cache.configValues === Object.values(config).join()) return cache.result; + else if(cache) + console.debug("[CSP] Policy changed! Recalculating cache..."); + else + console.debug("[CSP] Initializing cache for quicker responses..."); cache = { configValues: Object.values(config).join(), result: CSP.merge( diff --git a/sources/code/main/windows/main.ts b/sources/code/main/windows/main.ts index db2fda52..7d4cab62 100644 --- a/sources/code/main/windows/main.ts +++ b/sources/code/main/windows/main.ts @@ -97,10 +97,8 @@ export default function createMainWindow(flags:MainWindowFlags): BrowserWindow { win.webContents.session.webRequest.onHeadersReceived((details, callback) => { const headersOverwrite:{"Content-Security-Policy"?:[string]} = {}; - if (configData.get().settings.advanced.csp.enabled) { - console.debug("[CSP] Overwritting Discord CSP."); + if (configData.get().settings.advanced.csp.enabled) headersOverwrite["Content-Security-Policy"] = [getWebCordCSP().toString()]; - } callback({ responseHeaders: { ...details.responseHeaders,