chrome.runtime.onMessage.addListener((m, n)=> {
  var nh = chrome.runtime.connectNative("org.sandpoints.chromeext")
  nh.onDisconnect.addListener((e, err)=> {
    console.log("event:", e)
    console.log("error:", err)
  })
  console.log("message:", m)
  console.log("sender:", n)
  nh.postMessage(m);
  nh.onMessage.addListener((m, n)=> {
    console.log("native host message:", m)
    console.log("native host sender:", n)  
    if (m.Response != "false") {
      chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
        chrome.tabs.sendMessage(tabs[0].id, { msg: m.response }, (response) => {
          if (response) {
            console.log(response)
          }
        });
      })
    }
  })
})


