Skip to content

Commit

Permalink
feat: disable backgroundThrottling
Browse files Browse the repository at this point in the history
  • Loading branch information
KochiyaOcean committed Oct 13, 2023
1 parent 5447029 commit 6d10a69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ app.on('ready', () => {
enableRemoteModule: true,
contextIsolation: false,
spellcheck: false,
backgroundThrottling: false,
},
backgroundColor: '#00000000',
backgroundMaterial: 'acrylic',
Expand Down
7 changes: 6 additions & 1 deletion lib/webcontent-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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')) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6d10a69

Please sign in to comment.