window.onload = function () {
  // Use menu API to show context menu.
  window.InspectorFrontendHost.showContextMenuAtPoint = createMenu

  // Use dialog API to override file chooser dialog.
  window.WebInspector.createFileSelectorElement = createFileSelectorElement
}

var convertToMenuTemplate = function (items) {
  var fn, i, item, len, template
  template = []
  fn = function (item) {
    var transformed
    transformed = item.type === 'subMenu' ? {
      type: 'submenu',
      label: item.label,
      enabled: item.enabled,
      submenu: convertToMenuTemplate(item.subItems)
    } : item.type === 'separator' ? {
      type: 'separator'
    } : item.type === 'checkbox' ? {
      type: 'checkbox',
      label: item.label,
      enabled: item.enabled,
      checked: item.checked
    } : {
      type: 'normal',
      label: item.label,
      enabled: item.enabled
    }
    if (item.id != null) {
      transformed.click = function () {
        window.DevToolsAPI.contextMenuItemSelected(item.id)
        return window.DevToolsAPI.contextMenuCleared()
      }
    }
    return template.push(transformed)
  }
  for (i = 0, len = items.length; i < len; i++) {
    item = items[i]
    fn(item)
  }
  return template
}

var createMenu = function (x, y, items) {
  const remote = require('electron').remote
  const Menu = remote.Menu
  const menu = Menu.buildFromTemplate(convertToMenuTemplate(items))

  // The menu is expected to show asynchronously.
  return setTimeout(function () {
    return menu.popup(remote.getCurrentWindow())
  })
}

var showFileChooserDialog = function (callback) {
  var dialog, files, remote
  remote = require('electron').remote
  dialog = remote.dialog
  files = dialog.showOpenDialog({})
  if (files != null) {
    return callback(pathToHtml5FileObject(files[0]))
  }
}

var pathToHtml5FileObject = function (path) {
  var blob, fs
  fs = require('fs')
  blob = new Blob([fs.readFileSync(path)])
  blob.name = path
  return blob
}

var createFileSelectorElement = function (callback) {
  var fileSelectorElement
  fileSelectorElement = document.createElement('span')
  fileSelectorElement.style.display = 'none'
  fileSelectorElement.click = showFileChooserDialog.bind(this, callback)
  return fileSelectorElement
}

@@ -263,19 +263,21 @@
 ment%0A%7D%0A%0A
-var
+const
  convert
@@ -318,62 +318,25 @@
 %7B%0A  
-var fn, i, item, len, template%0A  template = %5B%5D%0A  fn = 
+return items.map(
 func
@@ -357,27 +357,13 @@
     
-var transformed%0A   
+const
  tra
@@ -822,24 +822,25 @@
 abled%0A    %7D%0A
+%0A
     if (item
@@ -1019,24 +1019,25 @@
     %7D%0A    %7D%0A
+%0A
     return t
@@ -1039,22 +1039,8 @@
 urn 
-template.push(
 tran
@@ -1050,125 +1050,22 @@
 rmed
-)
 %0A  %7D
-%0A  for (i = 0, len = items.length; i %3C len; i++) %7B%0A    item = items%5Bi%5D%0A    fn(item)%0A  %7D%0A  return template%0A%7D%0A%0Avar
+)%0A%7D%0A%0Aconst
  cre
@@ -1107,22 +1107,24 @@
   const 
+%7B
 remote
+%7D
  = requi
@@ -1137,23 +1137,16 @@
 ectron')
-.remote
 %0A  const
@@ -1146,20 +1146,22 @@
   const 
+%7B
 Menu
+%7D
  = remot
@@ -1165,13 +1165,8 @@
 mote
-.Menu
 %0A  c
@@ -1283,23 +1283,16 @@
 usly.%0A  
-return 
 setTimeo
@@ -1312,23 +1312,16 @@
 ) %7B%0A    
-return 
 menu.pop
@@ -1358,19 +1358,21 @@
   %7D)%0A%7D%0A%0A
-var
+const
  showFil
@@ -1416,42 +1416,22 @@
 %7B%0A  
-var dialog, files, remote%0A  remote
+const %7Bdialog%7D
  = r
@@ -1462,32 +1462,13 @@
 e%0A  
-dialog = remote.dialog%0A 
+const
  fil
@@ -1525,23 +1525,16 @@
 ) %7B%0A    
-return 
 callback
@@ -1574,19 +1574,21 @@
 %0A  %7D%0A%7D%0A%0A
-var
+const
  pathToH
@@ -1628,22 +1628,13 @@
 %7B%0A  
-var blob, fs%0A 
+const
  fs 
@@ -1647,24 +1647,30 @@
 ire('fs')%0A  
+const 
 blob = new B
@@ -1734,19 +1734,21 @@
 blob%0A%7D%0A%0A
-var
+const
  createF
@@ -1796,33 +1796,13 @@
 %7B%0A  
-var fileSelectorElement%0A 
+const
  fil

Use const instead of var