Set loadURL at launch and remember to next launch?


#1

I am building an Electron JS app which when launched the user should be prompted to input a part of an URL. The user inputs myuserurl and this should be translated to https://example.com/myuserurl and then loaded when the app launches. At the next launch of the application, I want it to be remembered. But by clicking a keyboard shortcut button I want the user to be able to modify this input.

const {app, BrowserWindow} = require('electron')

let mainWindow

app.on('ready', () => {
  // Create main browser window
  mainWindow = new BrowserWindow({
    show: false,
    kiosk: true,
    alwaysOnTop: true,
    minimizable: false,
    webPreferences: {nodeIntegration: false}
  });
  // Create splash screen
  splash = new BrowserWindow({
    width: 800,
    height: 450,
    transparent: true,
    frame: false,
    alwaysOnTop: true
  });
  splash.loadURL(`file://${__dirname}/splash/splash.html`);
  mainWindow.loadURL('https://example.com');
  });


  // Disable menu
  mainWindow.setMenu(null);

  // When main window is ready to show, destroy the splash screen and show main window
  mainWindow.once('ready-to-show', () => {
    splash.destroy();
    mainWindow.show();
  });
});

I have searched high and low for a code snippet which provides this, but I haven’t found anything close to it.