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) => { 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")) { if (config.get("options.overrideUserAgent")) {
// User agents are from https://developers.whatismybrowser.com/useragents/explore/ // User agents are from https://developers.whatismybrowser.com/useragents/explore/
const originalUserAgent = win.webContents.userAgent; const originalUserAgent = win.webContents.userAgent;
@ -506,13 +497,12 @@ function removeContentSecurityPolicy(
// Custom listener to tweak the content security policy // Custom listener to tweak the content security policy
session.webRequest.onHeadersReceived(function (details, callback) { session.webRequest.onHeadersReceived(function (details, callback) {
if ( details.responseHeaders ??= {}
!details.responseHeaders["content-security-policy-report-only"] &&
!details.responseHeaders["content-security-policy"] // Remove the content security policy
)
return callback({ cancel: false });
delete details.responseHeaders["content-security-policy-report-only"]; delete details.responseHeaders["content-security-policy-report-only"];
delete details.responseHeaders["content-security-policy"]; delete details.responseHeaders["content-security-policy"];
callback({ cancel: false, responseHeaders: details.responseHeaders }); callback({ cancel: false, responseHeaders: details.responseHeaders });
}); });

View File

@ -71,10 +71,10 @@
"test:debug": "DEBUG=pw:browser* playwright test", "test:debug": "DEBUG=pw:browser* playwright test",
"start": "electron .", "start": "electron .",
"start:debug": "ELECTRON_ENABLE_LOGGING=1 electron .", "start:debug": "ELECTRON_ENABLE_LOGGING=1 electron .",
"icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated", "icon": "del-cli -f \"assets/generated\" && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated",
"generate:package": "node utils/generate-package-json.js", "generate:package": "node utils/generate-package-json.js",
"postinstall": "yarn run icon && yarn run plugins", "postinstall": "yarn run icon && yarn run plugins",
"clean": "del dist", "clean": "del-cli -f dist",
"build": "yarn run clean && electron-builder --win --mac --linux", "build": "yarn run clean && electron-builder --win --mac --linux",
"build:linux": "yarn run clean && electron-builder --linux", "build:linux": "yarn run clean && electron-builder --linux",
"build:mac": "yarn run clean && electron-builder --mac dmg:x64", "build:mac": "yarn run clean && electron-builder --mac dmg:x64",
@ -83,21 +83,21 @@
"lint": "xo", "lint": "xo",
"changelog": "auto-changelog", "changelog": "auto-changelog",
"plugins": "yarn run plugin:adblocker", "plugins": "yarn run plugin:adblocker",
"plugin:adblocker": "rimraf plugins/adblocker/ad-blocker-engine.bin && node plugins/adblocker/blocker.js", "plugin:adblocker": "del-cli -f \"plugins/adblocker/ad-blocker-engine.bin\" && node plugins/adblocker/blocker.js",
"release:linux": "yarn run clean && electron-builder --linux -p always -c.snap.publish=github", "release:linux": "yarn run clean && electron-builder --linux -p always -c.snap.publish=github",
"release:mac": "yarn run clean && electron-builder --mac -p always", "release:mac": "yarn run clean && electron-builder --mac -p always",
"release:win": "yarn run clean && electron-builder --win -p always" "release:win": "yarn run clean && electron-builder --win -p always"
}, },
"engines": { "engines": {
"node": ">=16.0.0", "node": ">=16.0.0",
"npm": "Please use yarn and not npm" "npm": "Please use yarn instead"
}, },
"dependencies": { "dependencies": {
"@cliqz/adblocker-electron": "^1.25.1", "@cliqz/adblocker-electron": "^1.25.1",
"@ffmpeg/core": "^0.11.0", "@ffmpeg/core": "^0.11.0",
"@ffmpeg/ffmpeg": "^0.11.6", "@ffmpeg/ffmpeg": "^0.11.6",
"@foobar404/wave": "^2.0.4", "@foobar404/wave": "^2.0.4",
"Simple-YouTube-Age-Restriction-Bypass": "https://gitpkg.now.sh/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/dist?v2.5.4", "@xhayper/discord-rpc": "^1.0.15",
"async-mutex": "^0.4.0", "async-mutex": "^0.4.0",
"browser-id3-writer": "^4.4.0", "browser-id3-writer": "^4.4.0",
"butterchurn": "^2.6.7", "butterchurn": "^2.6.7",
@ -105,7 +105,6 @@
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"custom-electron-prompt": "^1.5.1", "custom-electron-prompt": "^1.5.1",
"custom-electron-titlebar": "^4.1.5", "custom-electron-titlebar": "^4.1.5",
"discord-rpc": "^4.0.1",
"electron-better-web-request": "^1.0.1", "electron-better-web-request": "^1.0.1",
"electron-debug": "^3.2.0", "electron-debug": "^3.2.0",
"electron-is": "^3.0.0", "electron-is": "^3.0.0",
@ -119,6 +118,7 @@
"mpris-service": "^2.1.2", "mpris-service": "^2.1.2",
"node-fetch": "^2.6.8", "node-fetch": "^2.6.8",
"node-notifier": "^10.0.1", "node-notifier": "^10.0.1",
"simple-youtube-age-restriction-bypass": "zerodytrash/Simple-YouTube-Age-Restriction-Bypass#v2.5.4",
"vudio": "^2.1.1", "vudio": "^2.1.1",
"ytdl-core": "^4.11.1", "ytdl-core": "^4.11.1",
"ytpl": "^2.3.0" "ytpl": "^2.3.0"
@ -134,11 +134,6 @@
"playwright": "^1.29.2", "playwright": "^1.29.2",
"xo": "^0.53.1" "xo": "^0.53.1"
}, },
"resolutions": {
"glob-parent": "5.1.2",
"minimist": "1.2.7",
"yargs-parser": "21.1.1"
},
"auto-changelog": { "auto-changelog": {
"hideCredit": true, "hideCredit": true,
"package": true, "package": true,

View File

@ -1,4 +1,4 @@
module.exports = () => { module.exports = () => {
// Preload adblocker to inject scripts/styles // Preload adblocker to inject scripts/styles
require("@cliqz/adblocker-electron-preload/dist/preload.cjs"); require("@cliqz/adblocker-electron-preload");
}; };

View File

@ -1,3 +1,4 @@
"use strict";
const Discord = require("@xhayper/discord-rpc"); const Discord = require("@xhayper/discord-rpc");
const { dev } = require("electron-is"); const { dev } = require("electron-is");
const { dialog, app } = require("electron"); const { dialog, app } = require("electron");
@ -161,7 +162,7 @@ module.exports = (win, { autoReconnect, activityTimoutEnabled, activityTimoutTim
}; };
module.exports.clear = () => { module.exports.clear = () => {
if (info.rpc) info.rpc.clearActivity(); if (info.rpc) info.rpc.user?.clearActivity();
clearTimeout(clearActivity); clearTimeout(clearActivity);
}; };

1543
yarn.lock

File diff suppressed because it is too large Load Diff