Describe the bug
CSS Imports do not work due to the wacky way you import css (appending it one after the other in a linear fashion)
Additionally, the mainWindow is loaded weirdly using a 5 second timeout, lets speed that up a bit
Replace double function call with something cleaner, call loadURL only after window is set up, and add a .once listener so that the window is shown once ready.
function launchGame() {
mainWindow.setBackgroundColor('#000000');
mainWindow.setSize(1600, 900);
mainWindow.center();
mainWindow.removeMenu();
if (userPrefs['fullscreen'] == true) {
mainWindow.setFullScreen(true);
mainWindowIsFullscreen = true;
}
mainWindow.loadURL(url.format({
pathname: 'https://krunker.io',
icon: __dirname + 'src/cat.ico' // Doesn't work anymore just ignore it
}));
mainWindow.once('ready-to-show', () => {
splashWindow.destroy();
mainWindow.webContents.send('injectClientCSS', clientCSS);
mainWindow.webContents.send('injectCustomCSS', customCSS);
mainWindow.show();
});
}
Add show: false to mainWindow so that we do not have to hide it after creation
//Make the window
mainWindow = new BrowserWindow({
autoHideMenuBar: true,
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
enableBlinkFeatures: 'enable-heavy-ad-intervention'
}
});
Read custom css before showing mainWindow and cache it.. The css is then injected once the window is shown.
Preload.jsReplace single CSS function with 2: one for client css and one for custom
ipcRenderer.on('injectClientCSS', (event, css) => {
let s = document.createElement("style");
s.setAttribute("id", "gatoclientCSS");
s.innerHTML = css;
document.getElementsByTagName("body")[0].appendChild(s);
});
ipcRenderer.on('injectCustomCSS', (event, css) => {
let s = document.createElement("style");
s.setAttribute("id", "customCSS");
s.innerHTML = css;
document.getElementsByTagName("body")[0].appendChild(s);
});
Additional requests
Please provide a way to skip the auto update process to improve launch performance.
Also please, please remove that 35MB gif file and replace it with something more efficient to save on bandwidth.
Describe the bug CSS Imports do not work due to the wacky way you import css (appending it one after the other in a linear fashion) Additionally, the mainWindow is loaded weirdly using a 5 second timeout, lets speed that up a bit
Fix
Main.js
Replace double function call with something cleaner, call loadURL only after window is set up, and add a .once listener so that the window is shown once ready.
Add show: false to mainWindow so that we do not have to hide it after creation
Read custom css before showing mainWindow and cache it.. The css is then injected once the window is shown.
Preload.js Replace single CSS function with 2: one for client css and one for custom
Additional requests Please provide a way to skip the auto update process to improve launch performance. Also please, please remove that 35MB gif file and replace it with something more efficient to save on bandwidth.