'use strict';

const openLabelledId = "open-labelled";

browser.menus.create({
  id: openLabelledId,
  title: "Open",
  contexts: ["link"]
});

browser.menus.onClicked.addListener((info, tab) => {
  if (info.menuItemId === openLabelledId) {
    browser.tabs.update(tab.id, {
      url: info.linkUrl
    });
  }
});

async function updateMenuItem(linkHostname) {
  await browser.menus.update(openLabelledId, {
    title: `Open (${linkHostname})`
  });
  await browser.menus.refresh();
}

browser.menus.onShown.addListener(info => {
  if (!info.linkUrl) {
    return;
  }
  let linkElement = document.createElement("a");
  linkElement.href = info.linkUrl;
  updateMenuItem(linkElement.hostname);
});

@@ -313,14 +313,8 @@
 );%0A%0A
-async 
 func
@@ -351,22 +351,16 @@
 me) %7B%0A  
-await 
 browser.
@@ -438,14 +438,8 @@
 ;%0A  
-await 
 brow

Make menus calls synch (#345)