bitburner-src/electron/main.js

39 lines
928 B
JavaScript
Raw Normal View History

const { app, BrowserWindow, Menu, globalShortcut, shell } = require("electron");
2021-09-21 19:29:16 +02:00
2021-09-15 18:22:36 +02:00
Menu.setApplicationMenu(false);
function createWindow() {
const win = new BrowserWindow({
show: false,
webPreferences: {
// devTools: true,
2021-09-15 18:22:36 +02:00
},
});
win.removeMenu();
win.maximize();
win.loadFile("index.html");
win.show();
// win.webContents.openDevTools();
2021-09-21 19:29:16 +02:00
globalShortcut.register("f5", function () {
win.loadFile("index.html");
});
globalShortcut.register("f8", function () {
win.loadFile("index.html", { query: { noScripts: "true" } });
});
win.webContents.on("new-window", function (e, url) {
// make sure local urls stay in electron perimeter
2021-09-25 07:26:03 +02:00
if (url.substr(0, "file://".length) === "file://") {
return;
}
// and open every other protocols on the browser
e.preventDefault();
shell.openExternal(url);
});
2021-09-15 18:22:36 +02:00
}
app.whenReady().then(() => {
createWindow();
});