;(function(window, document, $, chrome){

  'use strict';

  var getOptions = function(){
    chrome.storage.local.get(function(data){
      if(data.token){
        $('#token').val(data.token);
      }
      if(data.channel){
        $('#channel').val(data.channel);
      }
    });
  };

  var clearOptions = function(){
    chrome.storage.local.clear(function(){
      $('#token').val('');
      $('#channel').val('');
    });
  };

  var saveOptions = function(token, channel, $success_el){
    chrome.storage.local.set({
      'token': token,
      'channel': channel
    }, function(){
      $success_el.fadeIn();
    });
  };

  var checkToken = function(token) {
    return $.ajax({
      type: 'GET',
      url: 'https://slack.com/api/auth.test',
      data: { token: token }
    });
  };

  $(document).ready(function(){
    var $info_el = $('#info-message');

    getOptions();

    $('#save').click(function(e){
      e.preventDefault();
      saveOptions($('#token').val(), $('#channel').val(), $(this).find('.icon'));
    });

    $('#clear').click(function(e){
      e.preventDefault();
      clearOptions();
    });

    $('#check').click(function(e){
      e.preventDefault();
      var $success_el = $(this).find('.icon');

      checkToken($('#token').val()).then(function(resp){
        if(resp.ok){
          $success_el.fadeIn();
        }
        else{
          $info_el.find('.icon').show();
          $info_el.find('span').text(resp.error.replace(/_/g, ' '));
        }
      }).fail(function(){
        $info_el.find('span').text('network error');
      });
    });

    $('input').on('keyup', function(){
      $('.icon-exclamation-circle, .icon-check').hide();
      $('span').text('');
    });

    $('#help').click(function(e){
      e.preventDefault();
      $('#help-contents').toggle();
    });

  });

})(window, document, jQuery, chrome);

;(function(window, document, $, chrome){

  'use strict';

  var getSavedOptions = function(){
    var dfd = $.Deferred();
    chrome.storage.local.get(function(data){
      dfd.resolve(data);
    });
    return dfd;
  };

  var clearOptions = function(){
    var dfd = $.Deferred();
    chrome.storage.local.clear(function(){
      dfd.resolve();
    });
    return dfd;
  };

  var saveOptions = function(token, channel){
    var dfd = $.Deferred();
    chrome.storage.local.set({
      'token': token,
      'channel': channel
    }, function(){
      dfd.resolve();
    });
    return dfd;
  };

  var checkToken = function(token) {
    return $.ajax({
      type: 'GET',
      url: 'https://slack.com/api/auth.test',
      data: { token: token }
    });
  };

  var humanize = function(str){
    return str.replace(/_/g, ' ');
  };

  $(document).ready(function(){

    //Cache Elements
    var $info_el = $('#info-message');
    var $info_icon = $info_el.find('.icon');
    var $info_text = $info_el.find('span');
    var $token_el = $('#token');
    var $channel_el = $('#channel');

    //Get saved option and show their values in input elements
    getSavedOptions().then(function(data){
      if(data.token){
        $token_el.val(data.token);
      }
      if(data.channel){
        $channel_el.val(data.channel);
      }
    });

    //Register Handlers
    $('#save').click(function(e){
      e.preventDefault();
      var $success_el = $(this).find('.icon');

      saveOptions($token_el.val(), $channel_el.val()).done(function(){
        $success_el.fadeIn();
      });
    });

    $('#clear').click(function(e){
      e.preventDefault();
      clearOptions().then(function(){
        $token_el.val('');
        $channel_el.val('');
      });
    });

    $('#check').click(function(e){
      e.preventDefault();
      var $success_el = $(this).find('.icon');

      checkToken($token_el.val()).done(function(resp){
        if(resp.ok){
          $success_el.fadeIn();
        }
        else{
          $info_icon.show();
          $info_text.text(humanize(resp.error));
        }
      }).fail(function(){
        $info_text.text('network error');
      });
    });

    $('input').on('keyup', function(){
      $('.icon-exclamation-circle, .icon-check').hide();
      $info_text.text('');
    });

    $('#help').click(function(e){
      e.preventDefault();
      $('#help-contents').toggle();
    });

  });

})(window, document, jQuery, chrome);

Improve options js code