code: function setupCommunications() {
    // Initiate a connection to the background page that we can use as a
    // channel for settings saving/etc.
    var port = chrome.extension.connect({
      name: 'injector'
    });
  
    // Listen for data from the extension.
    port.onMessage.addListener(function(data, port) {
      // We try to keep the data opaque so we don't waste any time here.
      sendMessage(data);
    });
  
    // Setup a communication channel with the page via events.
    var localId = String(Number(Date.now()));
    window.addEventListener('message', function(e) {
      // The message here is from the wtf.ipc.MessageChannel, and has some header
      // data in it.
      // Note that because we are also sending messages it's possible to get
      // our own messages back, so filter that by localId.
      var packet = e.data;
      if (!packet ||
          !packet['wtf_ipc_connect_token'] ||
          packet['wtf_ipc_sender_token'] == localId) {
        return;
      }
      var data = packet['data'];
  
      e.stopPropagation();
  
      // NOTE: Chrome ports do not support transferrables! Need to convert!
  
      // Pass through the messages.
      // We trust the Chrome security model and just send the data along.
      port.postMessage(data);
    }, false);
  
    function sendMessage(data) {
      var packet = {
        'wtf_ipc_connect_token': true,
        'wtf_ipc_sender_token': localId,
        'data': data
      };
      window.postMessage(packet, '*');
    };
  }
docs: Sets up two-way communications with the page.
  This enables proxying to the background page.