mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: fix It Just Works
Fixed an issue that caused inconsistent execution results.
This commit is contained in:
3
index.ts
3
index.ts
@ -8,7 +8,7 @@ import { autoUpdater } from 'electron-updater';
|
||||
import electronDebug from 'electron-debug';
|
||||
|
||||
import config from './config';
|
||||
import { setApplicationMenu } from './menu';
|
||||
import { refreshMenu, setApplicationMenu } from './menu';
|
||||
import { fileExists, injectCSS, injectCSSAsFile } from './plugins/utils';
|
||||
import { isTesting } from './utils/testing';
|
||||
import { setUpTray } from './tray';
|
||||
@ -470,6 +470,7 @@ app.on('ready', async () => {
|
||||
|
||||
mainWindow = await createMainWindow();
|
||||
setApplicationMenu(mainWindow);
|
||||
refreshMenu(mainWindow);
|
||||
setUpTray(app, mainWindow);
|
||||
|
||||
setupProtocolHandler(mainWindow);
|
||||
|
||||
20
menu.ts
20
menu.ts
@ -62,13 +62,15 @@ const pluginEnabledMenu = (plugin: string, label = '', hasSubmenu = false, refre
|
||||
},
|
||||
});
|
||||
|
||||
export const refreshMenu = (win: BrowserWindow) => {
|
||||
setApplicationMenu(win);
|
||||
if (inAppMenuActive) {
|
||||
win.webContents.send('refreshMenu');
|
||||
}
|
||||
};
|
||||
|
||||
export const mainMenuTemplate = (win: BrowserWindow): MenuTemplate => {
|
||||
const refreshMenu = () => {
|
||||
setApplicationMenu(win);
|
||||
if (inAppMenuActive) {
|
||||
win.webContents.send('refreshMenu');
|
||||
}
|
||||
};
|
||||
const innerRefreshMenu = () => refreshMenu(win);
|
||||
|
||||
return [
|
||||
{
|
||||
@ -84,15 +86,15 @@ export const mainMenuTemplate = (win: BrowserWindow): MenuTemplate => {
|
||||
const getPluginMenu = pluginMenus[pluginName as keyof typeof pluginMenus];
|
||||
|
||||
if (!config.plugins.isEnabled(pluginName)) {
|
||||
return pluginEnabledMenu(pluginName, pluginLabel, true, refreshMenu);
|
||||
return pluginEnabledMenu(pluginName, pluginLabel, true, innerRefreshMenu);
|
||||
}
|
||||
|
||||
return {
|
||||
label: pluginLabel,
|
||||
submenu: [
|
||||
pluginEnabledMenu(pluginName, 'Enabled', true, refreshMenu),
|
||||
pluginEnabledMenu(pluginName, 'Enabled', true, innerRefreshMenu),
|
||||
{ type: 'separator' },
|
||||
...getPluginMenu(win, config.plugins.getOptions(pluginName), refreshMenu),
|
||||
...getPluginMenu(win, config.plugins.getOptions(pluginName), innerRefreshMenu),
|
||||
],
|
||||
} satisfies Electron.MenuItemConstructorOptions;
|
||||
}
|
||||
|
||||
@ -21,8 +21,6 @@
|
||||
"!node_modules",
|
||||
"node_modules/custom-electron-prompt/**",
|
||||
"node_modules/@cliqz/adblocker-electron-preload/**",
|
||||
"node_modules/@cliqz/adblocker-content/**",
|
||||
"node_modules/@cliqz/adblocker-extended-selectors/**",
|
||||
"node_modules/@ffmpeg.wasm/core-mt/**",
|
||||
"!node_modules/**/*.map",
|
||||
"!node_modules/**/*.ts"
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
export default () => {
|
||||
const path = '@cliqz/adblocker-electron-preload'; // prevent require hoisting
|
||||
require(path);
|
||||
export default async () => {
|
||||
await import('@cliqz/adblocker-electron-preload');
|
||||
};
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import config from './config';
|
||||
import config, { shouldUseBlocklists } from './config';
|
||||
import inject from './inject';
|
||||
import injectCliqzPreload from './inject-cliqz-preload';
|
||||
|
||||
import { blockers } from './blocker-types';
|
||||
|
||||
export default async () => {
|
||||
if (await config.shouldUseBlocklists()) {
|
||||
if (shouldUseBlocklists()) {
|
||||
// Preload adblocker to inject scripts/styles
|
||||
injectCliqzPreload();
|
||||
await injectCliqzPreload();
|
||||
// eslint-disable-next-line @typescript-eslint/await-thenable
|
||||
} else if ((await config.get('blocker')) === blockers.InPlayer) {
|
||||
} else if ((config.get('blocker')) === blockers.InPlayer) {
|
||||
inject();
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export default () => {
|
||||
export default async () => {
|
||||
// See https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass#userscript
|
||||
import('simple-youtube-age-restriction-bypass');
|
||||
await import('simple-youtube-age-restriction-bypass');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user