feat: apply suggestion

This commit is contained in:
xhayper
2023-01-15 10:59:56 +07:00
parent dbfddebbc2
commit 91e111d483
5 changed files with 605 additions and 978 deletions

View File

@ -258,15 +258,6 @@ function createMainWindow() {
}
app.once("browser-window-created", (event, win) => {
electron.session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
"Content-Security-Policy": ["default-src 'self' music.youtube.com youtube.com accounts.google.com google.com"]
}
})
})
if (config.get("options.overrideUserAgent")) {
// User agents are from https://developers.whatismybrowser.com/useragents/explore/
const originalUserAgent = win.webContents.userAgent;
@ -506,13 +497,12 @@ function removeContentSecurityPolicy(
// Custom listener to tweak the content security policy
session.webRequest.onHeadersReceived(function (details, callback) {
if (
!details.responseHeaders["content-security-policy-report-only"] &&
!details.responseHeaders["content-security-policy"]
)
return callback({ cancel: false });
details.responseHeaders ??= {}
// Remove the content security policy
delete details.responseHeaders["content-security-policy-report-only"];
delete details.responseHeaders["content-security-policy"];
callback({ cancel: false, responseHeaders: details.responseHeaders });
});