extensions/wtf-injector-firefox/lib/main.js
function setupAddonBarWidget() {
  var panel = panels.Panel({
    width: 200,
    height: 128,
    contentURL: self.data.url('widget-panel.html'),
    contentScriptFile: self.data.url('widget-panel.js')
  });
  panel.on('show', function() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    if (!url.length) {
      panel.port.emit('show', null);
    } else {
      panel.port.emit('show', {
        'enabled': isInjectionEnabledForUrl(url)
      });
    }
  });
  panel.port.on('perform', function(action) {
    switch (action) {
      case 'toggle':
        toggleInjectionForActiveTab();
        panel.hide();
        break;
      case 'reset':
        resetOptionsForActiveTab();
        panel.hide();
        break;
      case 'show_ui':
        showUi();
        panel.hide();
        break;
    }
  });

  var widget = widgets.Widget({
    id: 'wtf-toggle',
    label: 'Toggle Web Tracing Framework',
    contentURL: self.data.url('widget.html'),
    contentScriptFile: self.data.url('widget.js'),
    panel: panel
  });

  // Update the widget icon when the URL changes.
  function tabChanged() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    widget.port.emit('update', {
      'enabled': url.length ? isInjectionEnabledForUrl(url) : false
    });
  };
  tabs.on('open', tabChanged);
  tabs.on('close', tabChanged);
  tabs.on('ready', tabChanged);
  tabs.on('activate', tabChanged);
  tabs.on('deactivate', tabChanged);
}
function setupAddonBarWidget() {
  var panel = panels.Panel({
    width: 200,
    height: 128,
    contentURL: self.data.url('widget-panel.html'),
    contentScriptFile: self.data.url('widget-panel.js')
  });
  panel.on('show', function() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    if (!url.length) {
      panel.port.emit('show', null);
    } else {
      panel.port.emit('show', {
        'enabled': isInjectionEnabledForUrl(url)
      });
    }
  });
  panel.port.on('perform', function(action) {
    switch (action) {
      case 'toggle':
        toggleInjectionForActiveTab();
        panel.hide();
        break;
      case 'reset':
        resetOptionsForActiveTab();
        panel.hide();
        break;
      case 'show_ui':
        showUi();
        panel.hide();
        break;
    }
  });

  var widget = widgets.Widget({
    id: 'wtf-toggle',
    label: 'Toggle Web Tracing Framework',
    contentURL: self.data.url('widget.html'),
    contentScriptFile: self.data.url('widget.js'),
    panel: panel
  });

  // Update the widget icon when the URL changes.
  function tabChanged() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    widget.port.emit('update', {
      'enabled': url.length ? isInjectionEnabledForUrl(url) : false
    });
  };
  tabs.on('open', tabChanged);
  tabs.on('close', tabChanged);
  tabs.on('ready', tabChanged);
  tabs.on('activate', tabChanged);
  tabs.on('deactivate', tabChanged);
}
function setupAddonBarWidget ( ) { var panel = panels . Panel ( { width : 200 , height : 128 , contentURL : self . data . url ( 'widget-panel.html' ) , contentScriptFile : self . data . url ( 'widget-panel.js' ) } ) ; panel . on ( 'show' , function ( ) { var url = getCanonicalUrl ( tabs . activeTab . url ) ; if ( ! url . length ) { panel . port . emit ( 'show' , null ) ; } else { panel . port . emit ( 'show' , { 'enabled' : isInjectionEnabledForUrl ( url ) } ) ; } } ) ; panel . port . on ( 'perform' , function ( action ) { switch ( action ) { case 'toggle' : toggleInjectionForActiveTab ( ) ; panel . hide ( ) ; break ; case 'reset' : resetOptionsForActiveTab ( ) ; panel . hide ( ) ; break ; case 'show_ui' : showUi ( ) ; panel . hide ( ) ; break ; } } ) ; var widget = widgets . Widget ( { id : 'wtf-toggle' , label : 'Toggle Web Tracing Framework' , contentURL : self . data . url ( 'widget.html' ) , contentScriptFile : self . data . url ( 'widget.js' ) , panel : panel } ) ; // Update the widget icon when the URL changes. function tabChanged ( ) { var url = getCanonicalUrl ( tabs . activeTab . url ) ; widget . port . emit ( 'update' , { 'enabled' : url . length ? isInjectionEnabledForUrl ( url ) : false } ) ; } ; tabs . on ( 'open' , tabChanged ) ; tabs . on ( 'close' , tabChanged ) ; tabs . on ( 'ready' , tabChanged ) ; tabs . on ( 'activate' , tabChanged ) ; tabs . on ( 'deactivate' , tabChanged ) ; }
Sets up the addon bar widget.
Sets up the addon bar widget .