title: Electron pass creator window id to new BrowserWindow
body: <p>I'm making an electron app that runs a custom script on a website in the background. This code is being executed in a second window created by the main window. The second window then creates another hidden window where the website will be loaded and the custom script will be run. I need to be able to pass the window id of the second window to the hidden window so when the custom script is finished running it can send an ipc message back specifically to the second window.</p>
  
  <p>I found an issue on <a href="https://github.com/electron/electron/issues/1095" rel="nofollow noreferrer">github</a> where someone answered in 2016 that it appeared you could assign custom values to win and then read them in the newly created window but I have had no success implementing that.</p>
  
  <pre><code>        // In second window
          const currentWindow = require('electron').remote.getCurrentWindow();
          // Create hidden window
          win = new BrowserWindow({ show: false });
          win.creatorId = currentWindow.id; // CUSTOM: Set creator window ID
          win.webContents.openDevTools();
          win.webContents.on('dom-ready', () =&gt; {
              // Load dependencies every time a new url is loaded
              win.webContents.executeJavaScript(`
                  const currentWindow = require('electron').remote.getCurrentWindow();
                  alert(currentWindow.creatorId); // This is undefined :(
                  const { BrowserWindow } = require('electron').remote;
                  const ipc = require('electron').ipcRenderer;
                  window.$ = window.jQuery = require('jquery');
              `);
          });
  
          ...
  
          worker.win.loadURL(`random.webpage`);
          // Run custom script on a website and send the result back to the creator window
          win.webContents.executeJavaScript(`
              $(document).ready(function () { 
  BrowserWindow.fromId(currentWindow.creatorId).webContents.send('coolMessage', {});
              });
      `);
  </code></pre>
  
  <p>When I try to read win.creatorId it is undefined. How can I identify the second window from the hidden window so I can send messages to it?</p>