Skip to content

Commit

Permalink
open external urls in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed May 6, 2021
1 parent 1297fc1 commit 90c3aaa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, shell } = require('electron');
const DiscordRPC = require('discord-rpc');
const startCase = require('lodash.startcase');
const path = require('path');
Expand Down Expand Up @@ -30,7 +30,8 @@ const createWindow = () => {
...opts,
webPreferences: {
webviewTag: true,
nodeIntegration: true
nodeIntegration: true,
nativeWindowOpen: true
}
});

Expand Down Expand Up @@ -70,6 +71,16 @@ app.on('activate', () => {
}
});

app.on('web-contents-created', (e, contents) => {
if(contents.getType() === 'webview') {

contents.addListener('will-navigate', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
}
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

Expand Down

0 comments on commit 90c3aaa

Please sign in to comment.