diff --git a/app.js b/app.js index 413ea49f3..217b44bba 100644 --- a/app.js +++ b/app.js @@ -255,6 +255,7 @@ app.on('ready', () => { enableRemoteModule: true, contextIsolation: false, spellcheck: false, + backgroundThrottling: false, }, backgroundColor: '#00000000', backgroundMaterial: 'acrylic', diff --git a/lib/webcontent-utils.ts b/lib/webcontent-utils.ts index 924aa3fd1..96198b824 100644 --- a/lib/webcontent-utils.ts +++ b/lib/webcontent-utils.ts @@ -7,7 +7,7 @@ import config from './config' const isModernDarwin = process.platform === 'darwin' && Number(os.release().split('.')[0]) >= 17 export function stopFileNavigate(id: number) { - webContents.fromId(id).addListener('will-navigate', (e, url) => { + webContents.fromId(id)?.addListener('will-navigate', (e, url) => { if (url.startsWith('file')) { e.preventDefault() } @@ -17,6 +17,10 @@ export function stopFileNavigate(id: number) { export function stopNavigateAndHandleNewWindow(id: number) { const webContent = webContents.fromId(id) + if (!webContent) { + return + } + webContent.addListener('will-navigate', (e, url) => { e.preventDefault() if (url.startsWith('http')) { @@ -61,6 +65,7 @@ export function stopNavigateAndHandleNewWindow(id: number) { if (frameName.startsWith('plugin[kangame]')) { options.useContentSize = true _.set(options, ['webPreferences', 'webSecurity'], false) + _.set(options, ['webPreferences', 'backgroundThrottling '], false) _.set(options, ['webPreferences', 'zoomFactor'], config.get('poi.appearance.zoom')) } return {