extensions/wtf-injector-chrome/popup.js
function buildAddonTable(addons, enabledAddons) {
  var tbody = document.querySelector('.addonPicker tbody');

  // Remove all old content.
  while (tbody.firstChild) {
    tbody.firstChild.remove();
  }

  // Add empty row.
  if (!addons.length) {
    var tr = document.createElement('tr');
    tr.className = 'emptyRow';
    var td = document.createElement('td');
    td.innerText = 'No addons added.';
    tr.appendChild(td);
    tbody.appendChild(tr);
  }

  // Build the table.
  for (var n = 0; n < addons.length; n++) {
    var extension = addons[n];
    addExtensionRow(extension);
  }
  function addExtensionRow(extension) {
    var isEnabled = enabledAddons.indexOf(extension.url) >= 0;;

    var td = document.createElement('td');
    var input = document.createElement('input');
    input.type = 'checkbox';
    input.checked = isEnabled;
    td.appendChild(input);
    var span = document.createElement('span');
    span.innerText = extension.manifest.name;
    span.title = extension.url;
    td.appendChild(span);

    var remove = document.createElement('td');
    remove.className = 'remove';
    var removeImg = document.createElement('img');
    removeImg.title = 'Remove extension';
    remove.appendChild(removeImg);

    var tr = document.createElement('tr');
    tr.appendChild(td);
    tr.appendChild(remove);

    tbody.appendChild(tr);

    function changed() {
      _gaq.push(['_trackEvent', 'popup', 'addon_toggled']);

      port.postMessage({
        command: 'toggle_extension',
        enabled: input.checked,
        url: extension.url
      });
    };
    input.onchange = function() {
      changed();
    };
    span.onclick = function() {
      input.checked = !input.checked;
      changed();
    };

    remove.onclick = function() {
      _gaq.push(['_trackEvent', 'popup', 'addon_removed']);

      if (isEnabled) {
        port.postMessage({
          command: 'toggle_addon',
          enabled: false,
          url: extension.url
        });
      }
      port.postMessage({
        command: 'remove_addon',
        url: extension.url
      });
    };
  };
}
function buildAddonTable(addons, enabledAddons) {
  var tbody = document.querySelector('.addonPicker tbody');

  // Remove all old content.
  while (tbody.firstChild) {
    tbody.firstChild.remove();
  }

  // Add empty row.
  if (!addons.length) {
    var tr = document.createElement('tr');
    tr.className = 'emptyRow';
    var td = document.createElement('td');
    td.innerText = 'No addons added.';
    tr.appendChild(td);
    tbody.appendChild(tr);
  }

  // Build the table.
  for (var n = 0; n < addons.length; n++) {
    var extension = addons[n];
    addExtensionRow(extension);
  }
  function addExtensionRow(extension) {
    var isEnabled = enabledAddons.indexOf(extension.url) >= 0;;

    var td = document.createElement('td');
    var input = document.createElement('input');
    input.type = 'checkbox';
    input.checked = isEnabled;
    td.appendChild(input);
    var span = document.createElement('span');
    span.innerText = extension.manifest.name;
    span.title = extension.url;
    td.appendChild(span);

    var remove = document.createElement('td');
    remove.className = 'remove';
    var removeImg = document.createElement('img');
    removeImg.title = 'Remove extension';
    remove.appendChild(removeImg);

    var tr = document.createElement('tr');
    tr.appendChild(td);
    tr.appendChild(remove);

    tbody.appendChild(tr);

    function changed() {
      _gaq.push(['_trackEvent', 'popup', 'addon_toggled']);

      port.postMessage({
        command: 'toggle_extension',
        enabled: input.checked,
        url: extension.url
      });
    };
    input.onchange = function() {
      changed();
    };
    span.onclick = function() {
      input.checked = !input.checked;
      changed();
    };

    remove.onclick = function() {
      _gaq.push(['_trackEvent', 'popup', 'addon_removed']);

      if (isEnabled) {
        port.postMessage({
          command: 'toggle_addon',
          enabled: false,
          url: extension.url
        });
      }
      port.postMessage({
        command: 'remove_addon',
        url: extension.url
      });
    };
  };
}
function buildAddonTable ( addons , enabledAddons ) { var tbody = document . querySelector ( '.addonPicker tbody' ) ; // Remove all old content. while ( tbody . firstChild ) { tbody . firstChild . remove ( ) ; } // Add empty row. if ( ! addons . length ) { var tr = document . createElement ( 'tr' ) ; tr . className = 'emptyRow' ; var td = document . createElement ( 'td' ) ; td . innerText = 'No addons added.' ; tr . appendChild ( td ) ; tbody . appendChild ( tr ) ; } // Build the table. for ( var n = 0 ; n < addons . length ; n ++ ) { var extension = addons [ n ] ; addExtensionRow ( extension ) ; } function addExtensionRow ( extension ) { var isEnabled = enabledAddons . indexOf ( extension . url ) >= 0 ; ; var td = document . createElement ( 'td' ) ; var input = document . createElement ( 'input' ) ; input . type = 'checkbox' ; input . checked = isEnabled ; td . appendChild ( input ) ; var span = document . createElement ( 'span' ) ; span . innerText = extension . manifest . name ; span . title = extension . url ; td . appendChild ( span ) ; var remove = document . createElement ( 'td' ) ; remove . className = 'remove' ; var removeImg = document . createElement ( 'img' ) ; removeImg . title = 'Remove extension' ; remove . appendChild ( removeImg ) ; var tr = document . createElement ( 'tr' ) ; tr . appendChild ( td ) ; tr . appendChild ( remove ) ; tbody . appendChild ( tr ) ; function changed ( ) { _gaq . push ( [ '_trackEvent' , 'popup' , 'addon_toggled' ] ) ; port . postMessage ( { command : 'toggle_extension' , enabled : input . checked , url : extension . url } ) ; } ; input . onchange = function ( ) { changed ( ) ; } ; span . onclick = function ( ) { input . checked = ! input . checked ; changed ( ) ; } ; remove . onclick = function ( ) { _gaq . push ( [ '_trackEvent' , 'popup' , 'addon_removed' ] ) ; if ( isEnabled ) { port . postMessage ( { command : 'toggle_addon' , enabled : false , url : extension . url } ) ; } port . postMessage ( { command : 'remove_addon' , url : extension . url } ) ; } ; } ; }
Builds the addon table.
@param {!Array.<!Object>} addons Addon information.
@param {!Array.<string>} enabledAddons Addons that are enabled.
Builds the addon table .