function prepare() {
  // Grab query args.
  // TODO(benvanik): is it possible we've already been switched here? Pull out
  //     'raw' version?
  var queryArgs = parseQueryString(window.location.search);

  // Grab out the target wtf-trace path.
  var databasePath = queryArgs['replay'];
  if (!databasePath || !databasePath.length) {
    throw new Error('Invalid replay= value in the query string.');
  }

  console.log('WTF Time Travel Replay enabled: ' + databasePath);

  // Pull out other relevant options from the query string.

  // Options to be passed to the popup.
  var options = {};

  // Create (or connect to) the controller popup.
  var childWindow = window.open(
      '',
      'wtf_replay_controller',
      'width=680,height=400,toolbar=0,status=0,scrollbars=0',
      true);

  // If the controller is new load it up with the WTF script.
  function writeToChild(strs) {
    for (var n = 0; n < strs.length; n++) {
      childWindow.document.writeln(strs[n]);
    }
  };
  var expectingReload = false;
  if (!childWindow.wtf) {
    if (queryArgs['uncompiled']) {
      writeToChild([
        '<link rel="stylesheet" href="../wtf_ui_styles_debug.css"></link>',
        '<script>window.CLOSURE_NO_DEPS = true;</script>',
        '<script src="../third_party/closure-library/closure/goog/base.js"></script>',
        '<script src="../wtf_js-deps.js"></script>',
        '<script>goog.require(\'wtf.replay.timeTravel\');</script>'
      ]);
    } else {
      writeToChild([
        '<link rel="stylesheet" href="../wtf_ui_styles_release.css"></link>',
        '<script src="../wtf_ui_js_compiled.js"></script>'
      ]);
    }
    writeToChild([
      '<body></body>'
    ]);

    // We will be reloaded afterwards, so don't do anything else.
    expectingReload = true;
  }

  // If the popup is new it'll get initialized and start loading. Otherwise
  // we'll reuse it.
  writeToChild([
    '<script>wtf.replay.timeTravel.setup("' +
        databasePath + '", ' + JSON.stringify(options) + ');</script>'
  ]);

  return !expectingReload;
}
Prepares the page for running replay.
This takes care of connecting to existing popups or opening a new one.
@return {boolean} Whether the session will continue. If false it's likely
    that the page will be reloaded soon.