message: cleaned up global and implicit var declarations
diff: * limitations under the License.
  *
  */
  +import browser from "webextension-polyfill";
  var selenium = new Selenium(BrowserBot.createForWindow(window));
  +let contentSideexTabId = window.contentSideexTabId;
  -function doCommands(request, sender, sendResponse, type) {
  +function doCommands(request, sender, sendResponse) {
  if (request.commands) {
  if (request.commands == "waitPreparation") {
  selenium["doWaitPreparation"]("", selenium.preprocessParameter(""));
  @@ -35,14 +37,14 @@ function doCommands(request, sender, sendResponse, type) {
  selenium["doDomWait"]("", selenium.preprocessParameter(""));
  sendResponse({ dom_time: window.sideex_new_page });
  } else {
  - var upperCase = request.commands.charAt(0).toUpperCase() + request.commands.slice(1);
  + const upperCase = request.commands.charAt(0).toUpperCase() + request.commands.slice(1);
  if (selenium["do" + upperCase] != null) {
  try {
  document.body.setAttribute("SideeXPlayingFlag", true);
  let returnValue = selenium["do"+upperCase](request.target,selenium.preprocessParameter(request.value));
  if (returnValue instanceof Promise) {
  // The command is a asynchronous function
  - returnValue.then(function(value) {
  + returnValue.then(function() {
  // Asynchronous command completed successfully
  document.body.removeAttribute("SideeXPlayingFlag");
  sendResponse({result: "success"});
  @@ -72,12 +74,12 @@ function doCommands(request, sender, sendResponse, type) {
  }
  return true;
  }
  + let targetSelecter;
  if (request.selectMode) {
  if (request.selecting) {
  targetSelecter = new TargetSelecter(function (element, win) {
  if (element && win) {
  - //var locatorBuilders = new LocatorBuilders(win);
  - var target = locatorBuilders.buildAll(element);
  + const target = locatorBuilders.buildAll(element);
  locatorBuilders.detach();
  if (target != null && target instanceof Array) {
  if (target) {
  @@ -86,17 +88,14 @@ function doCommands(request, sender, sendResponse, type) {
  selectTarget: true,
  target: target
  });
  - } else {
  - //alert("LOCATOR_DETECTION_FAILED");
  }
  }
  -
  }
  targetSelecter = null;
  }, function () {
  browser.runtime.sendMessage({
  cancelSelectTarget: true
  - })
  + });
  });
  } else {
  @@ -107,11 +106,6 @@ function doCommands(request, sender, sendResponse, type) {
  }
  }
  }
  -
  -}
  -
  -function doClick2(element) {
  - console.error("element:" + element);
  }
  browser.runtime.onMessage.addListener(doCommands);
  