diff --git a/src/background.html b/src/background.html
index 779a2c6..61819ef 100644
--- a/src/background.html
+++ b/src/background.html
@@ -8,7 +8,6 @@
 </head>
 <body>
 <script src="lib/dateFormat.min.js"></script>
-<script src="js/hotkey_storage.js"></script>
 <script src="js/background.js"></script>
 </body>
 </html>
diff --git a/src/js/account.js b/src/js/account.js
deleted file mode 100644
index d8ddd0d..0000000
--- a/src/js/account.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Create a user.
- * @param {Object} user
- *   properties: id, name, accessToken, expires, accessTokenSecret, albumId
- */
-var User = function(user) {
-  for (var prop in user) {
-    this[prop] = user[prop];
-  }
-};
-
-var Account = {
-
-  getUsers: function(siteId) {
-    var users = localStorage.getItem(siteId + '_userInfo');
-    if (users) {
-      users = JSON.parse(users);
-      for (var id in users) {
-        // Remove expired user.
-        if (Account.isExpires(users[id])) {
-          delete users[id];
-        }
-      }
-      localStorage.setItem(siteId + '_userInfo', JSON.stringify(users));
-      return users;
-    }
-    return {};
-  },
-
-  getUser: function(siteId, userId) {
-    var users = Account.getUsers(siteId);
-    var user = users[userId];
-    if (user && Account.isExpires(user)) {
-      Account.removeUser(siteId, userId);
-      return null;
-    } else {
-      return user;
-    }
-  },
-
-  addUser: function(siteId, user) {
-    var users = Account.getUsers(siteId);
-    var userId = user.id;
-    if (!users[userId]) {
-      users[userId] = user;
-      users = JSON.stringify(users);
-      localStorage.setItem(siteId + '_userInfo', users);
-    }
-  },
-
-  updateUser: function(siteId, user) {
-    var users = Account.getUsers(siteId);
-    var userId = user.id;
-    if (users && users[userId]) {
-      users[userId] = user;
-      users = JSON.stringify(users);
-      localStorage.setItem(siteId + '_userInfo', users);
-    }
-  },
-  
-  removeUser: function(siteId, userId) {
-    var users = Account.getUsers(siteId);
-    delete users[userId];
-    users = JSON.stringify(users);
-    localStorage.setItem(siteId + '_userInfo', users);
-  },
-
-  isExpires: function(user) {
-    var expires = user.expires;
-    if (expires) {
-      return new Date().getTime() >= expires;
-    }
-    return false;
-  }
-};
\ No newline at end of file
diff --git a/src/js/ajax.js b/src/js/ajax.js
deleted file mode 100644
index 2f3d4a5..0000000
--- a/src/js/ajax.js
+++ /dev/null
@@ -1,185 +0,0 @@
-(function(){
-  /**
-   * ajax is a encapsulated function that used to send data to server
-   * asynchronously. It uses XMLHttpRequest object to send textual or binary
-   * data through HTTP method GET, POST etc. It can custom request method,
-   * request header. Response can be parsed automatically by MIME type of
-   * response's Content-type, and it can handle success, error or progress event
-   * in course of sending request and retrieving response.
-   * @param {Object} option
-   */
-  function ajax(option) {
-    if (arguments.length < 1 || option.constructor != Object)
-      throw new Error('Bad parameter.');
-    var url = option.url;
-    var success = option.success;
-    var complete = option.complete;
-    if (!url || !(success || complete))
-      throw new Error('Parameter url and success or complete are required.');
-
-    var parameters = option.parameters || {};
-    var method = option.method || 'GET';
-    var status = option.status;
-    var headers = option.headers || {};
-    var data = option.data || null;
-    var multipartData = option.multipartData;
-    var queryString = constructQueryString(parameters);
-
-    if (multipartData) {
-      var boundary = multipartData.boundary || 'XMLHttpRequest2';
-      method = 'POST';
-      var multipartDataString;
-      var contentType = headers['Content-Type'] || 'multipart/form-data';
-      if (contentType.indexOf('multipart/form-data') == 0) {
-        headers['Content-Type'] = 'multipart/form-data; boundary=' + boundary;
-        multipartDataString = constructMultipartFormData(multipartData, boundary,
-          parameters);
-      } else if (contentType.indexOf('multipart/related') == 0) {
-        headers['Content-Type'] = 'multipart/related; boundary=' + boundary;
-        multipartDataString = constructMultipartRelatedData(boundary,
-          multipartData.dataList);
-      }
-
-      data = constructBufferData(multipartDataString);
-    } else {
-      if (queryString)
-        url += '?' + queryString;
-    }
-
-    var xhr = new XMLHttpRequest();
-    xhr.open(method, url, true);
-    xhr.onreadystatechange = function() {
-      if (xhr.readyState == 4) {
-        var statusCode = xhr.status;
-        var parsedResponse = parseResponse(xhr);
-        if (complete)
-          complete(statusCode, parsedResponse);
-        if (success && (statusCode == 200 || statusCode == 304)) {
-          success(parsedResponse);
-        } else if (status) {
-          if (status[statusCode]) {
-            // Call specified status code handler
-            status[statusCode](parsedResponse);
-          } else if (status['others']) {
-            // Call others status code handler
-            status['others'](parsedResponse, statusCode);
-          }
-        }
-      }
-    };
-
-    // Handle request progress
-    var progress = option.progress;
-    if (progress) {
-      xhr.upload.addEventListener('progress', function(e) {
-        // lengthComputable return true when the length of the progress is known
-        if (e.lengthComputable) {
-          progress(e.loaded, e.total);
-        }
-      }, false);
-    }
-    // Set request header
-    for (var headerKey in headers) {
-      xhr.setRequestHeader(headerKey, headers[headerKey]);
-    }
-
-    xhr.send(data);
-  }
-
-  function constructQueryString(parameters) {
-    var tmpParameter = [];
-    for(var name in parameters) {
-      var value = parameters[name];
-      if (value.constructor == Array) {
-        value.forEach(function(val) {
-          tmpParameter.push(name + '=' + val);
-        });
-      } else {
-        tmpParameter.push(name + '=' + value);
-      }
-    }
-    return tmpParameter.join('&');
-  }
-
-  // Parse response data according to content type of response
-  function parseResponse(xhr) {
-    var ct = xhr.getResponseHeader("content-type");
-    if (typeof ct == 'string') {
-      if (ct.indexOf('xml') >= 0)
-        return xhr.responseXML;
-      else if (ct.indexOf('json') >= 0)
-        return JSON.parse(xhr.responseText);
-    }
-    return xhr.responseText;
-  }
-
-  /**
-   * Construct multipart/form-data formatted data string.
-   * @param {Object} binaryData binary data
-   * @param {String} boundary boundary of parts
-   * @param {Object} otherParameters other text parameters
-   */
-  function constructMultipartFormData(binaryData, boundary, otherParameters) {
-    var commonHeader = 'Content-Disposition: form-data; ';
-    var data = [];
-    for (var key in otherParameters) {
-
-      // Add boundary of one header part
-      data.push('--' + boundary + '\r\n');
-
-      // Add same Content-Disposition information
-      data.push(commonHeader);
-      data.push('name="' + key + '"\r\n\r\n' + otherParameters[key] + '\r\n');
-    }
-
-    // Construct file data header
-    data.push('--' + boundary + '\r\n');
-    data.push(commonHeader);
-
-    data.push('name="' + (binaryData.name || 'binaryfilename') + '"; ');
-    data.push('filename=\"' + binaryData.value + '\"\r\n');
-    data.push('Content-type: ' + binaryData.type + '\r\n\r\n');
-    data.push(binaryData.data + '\r\n');
-
-    data.push('--' + boundary + '--\r\n');
-    return data.join('');
-  }
-
-  function constructBufferData(dataString, contentType) {
-      var len = dataString.length;
-
-      // Create a 8-bit unsigned integer ArrayBuffer view
-      var data = new Uint8Array(len);
-      for (var i = 0; i < len; i++) {
-        data[i] = dataString.charCodeAt(i);
-      }
-
-      return data.buffer
-  }
-
-  function constructMultipartRelatedData(boundary, dataList) {
-    var result = [];
-    dataList.forEach(function(data) {
-      result.push('--' + boundary + '\r\n');
-      result.push('Content-Type: ' + data.contentType + '\r\n\r\n');
-      result.push(data.data + '\r\n');
-    });
-    result.push('--' + boundary + '--\r\n');
-    return result.join('');
-  }
-
-  ajax.encodeForBinary = function(string) {
-    string = encodeURI(string).replace(/%([A-Z0-9]{2})/g, '%u00$1');
-    return unescape(string);
-  };
-
-  ajax.convertEntityString = function(string) {
-    var entitychars = ['<', '>', '&', '"', '\''];
-    var entities = ['&lt;', '&gt;', '&amp;', '&quot;', '&apos;'];
-    entitychars.forEach(function(character, index) {
-      string = string.replace(character, entities[index]);
-    });
-    return string;
-  };
-  window.ajax = ajax;
-})();
\ No newline at end of file
diff --git a/src/js/background.js b/src/js/background.js
index e3c030e..021bed3 100644
--- a/src/js/background.js
+++ b/src/js/background.js
@@ -20,53 +20,25 @@
   captureStatus: true,
   screenshotName: null,
 
-  handleHotKey: function(keyCode) {
-    if (HotKey.isEnabled()) {
-      switch (keyCode) {
-        case HotKey.getCharCode('area'):
-          screenshot.showSelectionArea();
-          break;
-        case HotKey.getCharCode('viewport'):
-          screenshot.captureWindow();
-          break;
-        case HotKey.getCharCode('fullpage'):
-          screenshot.captureWebpage();
-          break;
-        case HotKey.getCharCode('screen'):
-          screenshot.captureScreen();
-          break;
-      }
-    }
-  },
-
   /**
   * Receive messages from content_script, and then decide what to do next
   */
   addMessageListener: function() {
     chrome.extension.onMessage.addListener(function(request, sender, response) {
+      console.log(request);
       var obj = request;
-      var hotKeyEnabled = HotKey.isEnabled();
       switch (obj.msg) {
-        case 'capture_hot_key':
-          screenshot.handleHotKey(obj.keyCode);
-          break;
         case 'capture_selected':
           screenshot.captureSelected();
           break;
         case 'capture_window':
-          if (hotKeyEnabled) {
-            screenshot.captureWindow();
-          }
+          screenshot.captureWindow();
           break;
         case 'capture_area':
-          if (hotKeyEnabled) {
-            screenshot.showSelectionArea();
-          }
+          screenshot.showSelectionArea();
           break;
         case 'capture_webpage':
-          if (hotKeyEnabled) {
-            screenshot.captureWebpage();
-          }
+          screenshot.captureWebpage();
           break;
       }
     });
@@ -305,7 +277,6 @@
           for (var i = 0; i < tabs.length; ++i) {
             if (tabs[i].url.indexOf("chrome://") != 0) {
               chrome.tabs.executeScript(tabs[i].id, { file: 'js/page.js' });
-              chrome.tabs.executeScript(tabs[i].id, { file: 'js/shortcut.js' });
             }
           }
         });
diff --git a/src/js/facebook.js b/src/js/facebook.js
deleted file mode 100644
index 68cb091..0000000
--- a/src/js/facebook.js
+++ /dev/null
@@ -1,139 +0,0 @@
-const FB_APP_ID = CURRENT_LOCALE == 'zh_CN' ? 170328509685996 : 118170701590738;
-const FB_REDIRECT_URI = 'http://www.facebook.com/connect/login_success.html';
-const FB_PERMISSION = 'offline_access,user_photos,publish_stream';
-const FB_ACCESS_TOKEN_URL = 'https://www.facebook.com/dialog/oauth';
-const FB_PHOTO_UPLOAD_URL = 'https://graph.facebook.com/me/photos';
-const FB_USER_INFO_URL = 'https://graph.facebook.com/me';
-const FB_LOGOUT_URL = 'http://m.facebook.com/logout.php?confirm=1';
-
-var Facebook = {
-  siteId: 'facebook',
-  redirectUrl: FB_REDIRECT_URI,
-  currentUserId: null,
-  accessTokenCallback: null,
-
-  isRedirectUrl: function(url) {
-    return url.indexOf(FB_REDIRECT_URI) == 0;
-  },
-  
-  getAccessToken: function(callback) {
-    Facebook.accessTokenCallback = callback;
-    var url = FB_ACCESS_TOKEN_URL + '?client_id=' + FB_APP_ID +
-      '&redirect_uri=' + FB_REDIRECT_URI + '&scope=' + FB_PERMISSION +
-      '&response_type=token';
-    chrome.tabs.create({url: url});
-  },
-
-  parseAccessToken: function(url) {
-    var queryString = url.split('#')[1] || url.split('?')[1];
-    var queries = queryString.split('&');
-    var queryMap = {};
-    queries.forEach(function(pair) {
-      queryMap[pair.split('=')[0]] = pair.split('=')[1];
-    });
-    var accessToken = queryMap['access_token'];
-    if (accessToken) {
-      var user = new User({
-        accessToken: accessToken
-      });
-      Facebook.accessTokenCallback('success', user);
-    } else if (queryMap['error']) {
-      Facebook.accessTokenCallback('failure', 'user_denied');
-    }
-    Facebook.accessTokenCallback = null;
-  },
-
-  getUserInfo: function(user, callback) {
-    ajax({
-      url: FB_USER_INFO_URL,
-      parameters: {
-        'access_token': user.accessToken
-      },
-      success: function(userInfo) {
-        userInfo = JSON.parse(userInfo);
-        if (callback) {
-          user.id = userInfo.id;
-          user.name = userInfo.name;
-          callback('success', user);
-        }
-      },
-      status: {
-        others: function() {
-          if (callback)
-            callback('failure', 'failed_to_get_user_info');
-        }
-      }
-    });
-  },
-  
-  upload: function(user, caption, imageData, callback) {
-    caption = ajax.encodeForBinary(caption);
-    var params = {
-      'access_token': user.accessToken,
-      message: caption
-    };
-    
-    var binaryData = {
-      boundary: MULTIPART_FORMDATA_BOUNDARY,
-      data: imageData,
-      value: 'test.png',
-      type: 'image/png'
-    };
-    
-    ajax({
-      url: FB_PHOTO_UPLOAD_URL,
-      parameters: params,
-      multipartData: binaryData,
-      success: function(data) {
-        callback('success', JSON.parse(data).id);
-      },
-      status: {
-        others: function(data) {
-          var message;
-          if (data) {
-            data = JSON.parse(data);
-            if (data.error.message.indexOf('access token') >= 0) {
-              // User removed application permission
-              // {"error":{"type":"OAuthException",
-              // "message":"Error validating access token."}}
-              message = 'bad_access_token';
-            } else {
-              // {"error":{"type":"OAuthException",
-              // "message":"(#1) An unknown error occurred"}}
-              message = 'unknown_error';
-            }
-          } else {
-            message = 'failed_to_connect_to_server';
-          }
-          callback('failure', message);
-        }
-      }
-    });
-  },
-
-  getPhotoLink: function(user, photoId, callback) {
-    ajax({
-      url: 'https://graph.facebook.com/' + photoId,
-      parameters: {
-        'access_token': user.accessToken
-      },
-      complete: function(statusCode, data) {
-        if (statusCode == 200) {
-          callback('success', JSON.parse(data).link);
-        } else {
-          callback('failure', 'failed_to_get_photo_link');
-        }
-      }
-    });
-  },
-
-  logout: function(callback) {
-    ajax({
-      url: FB_LOGOUT_URL,
-      success: function(data) {
-        if (callback)
-          callback(data);
-      }
-    });
-  }
-};
\ No newline at end of file
diff --git a/src/js/hotkey_storage.js b/src/js/hotkey_storage.js
deleted file mode 100644
index 9cea0aa..0000000
--- a/src/js/hotkey_storage.js
+++ /dev/null
@@ -1,54 +0,0 @@
-var HotKey = (function() {
-  return {
-    setup: function() {
-      // Default enable hot key for capture.
-      if (!localStorage.getItem('hot_key_enabled'))
-        localStorage.setItem('hot_key_enabled', true);
-
-      // Set default hot key of capture, R V H P.
-      if (!this.get('area'))
-        this.set('area', 'R');
-      if (!this.get('viewport'))
-        this.set('viewport', 'V');
-      if (!this.get('fullpage'))
-        this.set('fullpage', 'H');
-      if (!this.get('screen'))
-        this.set('screen', 'P');
-
-      var screenCaptureHotKey = this.get('screen');
-      if (this.isEnabled()) {
-        this.set('screen', '@'); // Disable hot key for screen capture.
-      }
-    },
-
-    /**
-     * Set hot key by type.
-     * @param {String} type Hot key type, must be area/viewport/fullpage/screen.
-     * @param {String} value
-     */
-    set: function(type, value) {
-      var key = type + '_capture_hot_key';
-      localStorage.setItem(key, value);
-    },
-
-    get: function(type) {
-      return localStorage.getItem(type + '_capture_hot_key');
-    },
-
-    getCharCode: function(type) {
-      return this.get(type).charCodeAt(0);
-    },
-
-    enable: function() {
-      localStorage.setItem('hot_key_enabled', true);
-    },
-
-    disable: function(bg) {
-      localStorage.setItem('hot_key_enabled', false);
-    },
-
-    isEnabled: function() {
-      return localStorage.getItem('hot_key_enabled') == 'true';
-    }
-  }
-})();
diff --git a/src/js/imgur.js b/src/js/imgur.js
deleted file mode 100644
index cfc399f..0000000
--- a/src/js/imgur.js
+++ /dev/null
@@ -1,241 +0,0 @@
-(function() {
-  const IMGUR_APP_KEY = '90922ae86b91b09541d74134a5bb0f6404e0c378f';
-  const IMGUR_APP_SECRET = 'b100656ebf595b7464e428615b9bc703';
-  const IMGUR_REQUEST_TOKEN_URL = 'https://api.imgur.com/oauth/request_token';
-  const IMGUR_USER_AUTHENTICATION_URL = 'https://api.imgur.com/oauth/authorize';
-  const IMGUR_ACCESS_TOKEN_URL = 'https://api.imgur.com/oauth/access_token';
-  const IMGUR_USER_INFO_URL = 'http://api.imgur.com/2/account.json';
-  const IMGUR_PHOTO_UPLOAD_URL = 'http://api.imgur.com/2/account/images.json';
-  const IMGUR_LOGOUT_URL = 'http://imgur.com/logout';
-  const OAUTH_SIGNATURE_METHOD = 'HMAC-SHA1';
-  const OAUTH_VERSION = '1.0';
-
-  var Imgur = window.Imgur = {
-    siteId: 'imgur',
-    currentUserId: null,
-    currentUserOauthToken: '',
-    currentUserOauthTokenSecret: '',
-    accessTokenCallback: null,
-
-    isRedirectUrl: function() {},
-
-    getAuthorizationHeader: function(message, accessor) {
-      OAuth.setTimestampAndNonce(message);
-      OAuth.SignatureMethod.sign(message, accessor);
-      return OAuth.getAuthorizationHeader("", message.parameters);
-    },
-
-    getRequestToken: function(callback) {
-      Imgur.accessTokenCallback = callback;
-      var message = {
-        action: IMGUR_REQUEST_TOKEN_URL,
-        method: 'POST',
-        parameters: {
-          'oauth_consumer_key': IMGUR_APP_KEY,
-          'oauth_signature_method': OAUTH_SIGNATURE_METHOD,
-          'oauth_version': OAUTH_VERSION
-        }
-      };
-      var accessor = {
-        consumerKey: IMGUR_APP_KEY,
-        consumerSecret: IMGUR_APP_SECRET
-      };
-
-      // Get oauth signature header
-      var header = Imgur.getAuthorizationHeader(message, accessor);
-
-      ajax({
-        url: IMGUR_REQUEST_TOKEN_URL,
-        method: 'POST',
-        headers: {
-          'Authorization': header
-        },
-        success: function(response) {
-          parameters = OAuth.getParameterMap(response);
-          var oauth_token = parameters['oauth_token'];
-          var oauth_token_secret = parameters['oauth_token_secret'];
-          Imgur.currentUserOauthToken = oauth_token;
-          Imgur.currentUserOauthTokenSecret = oauth_token_secret;
-          Imgur.getUserAuthentication(oauth_token);
-        },
-        status: {
-          others: function() {
-            callback('failure', 'imgur_failed_to_get_request_token');
-          }
-        }
-      });
-    },
-
-    getUserAuthentication: function(oauth_token) {
-      var url = IMGUR_USER_AUTHENTICATION_URL + '?oauth_token=' + oauth_token +
-        '&oauth_callback=ready';
-      chrome.tabs.create({url: url}, function(tab) {
-          chrome.tabs.onUpdated.addListener(
-            function(tabId, changeInfo, _tab) {
-              if (tabId == tab.id && changeInfo.url
-                  && changeInfo.url.indexOf('oauth_verifier=') > 0) {
-                chrome.tabs.remove(tabId);
-                Imgur.parseAccessToken(changeInfo.url);
-              }
-            });
-        });
-    },
-
-    parseAccessToken: function(url) {
-      var oauth_verifier = OAuth.getParameter(url, 'oauth_verifier');
-      Imgur.getAccessToken(Imgur.accessTokenCallback, oauth_verifier);
-      Imgur.accessTokenCallback = null;
-    },
-
-    getAccessToken: function(callback, oauth_verifier) {
-      if (!oauth_verifier) {
-        Imgur.getRequestToken(callback);
-        return;
-      }
-      var message = {
-        action: IMGUR_ACCESS_TOKEN_URL,
-        method: 'POST',
-        parameters: {
-          'oauth_consumer_key': IMGUR_APP_KEY,
-          'oauth_token': Imgur.currentUserOauthToken,
-          'oauth_token_secret': Imgur.currentUserOauthTokenSecret,
-          'oauth_signature_method': OAUTH_SIGNATURE_METHOD,
-          'oauth_verifier': oauth_verifier,
-          'oauth_version': OAUTH_VERSION
-        }
-      };
-      var accessor = {
-        consumerKey: IMGUR_APP_KEY,
-        consumerSecret: IMGUR_APP_SECRET,
-        tokenSecret: Imgur.currentUserOauthTokenSecret
-      };
-      var header = Imgur.getAuthorizationHeader(message, accessor);
-
-      ajax({
-        url: IMGUR_ACCESS_TOKEN_URL,
-        method: 'POST',
-        headers: {
-          'Authorization': header
-        },
-        success: function(response) {
-          responseMap = OAuth.getParameterMap(response);
-          var accessToken = responseMap.oauth_token;
-          var accessTokenSecret = responseMap.oauth_token_secret;
-          var user = new User({
-            id: null,
-            accessToken: accessToken,
-            accessTokenSecret: accessTokenSecret
-          });
-
-          callback('success', user);
-        },
-        status: {
-          others: function(data) {
-            callback('failure', 'imgur_failed_to_get_access_token');
-          }
-        }
-      });
-    },
-
-    getUserInfo: function(user, callback) {
-      var url = IMGUR_USER_INFO_URL;
-      var message = {
-        action: url,
-        method: 'GET',
-        parameters: {
-          'oauth_consumer_key': IMGUR_APP_KEY,
-          'oauth_token': user.accessToken,
-          'oauth_signature_method': OAUTH_SIGNATURE_METHOD,
-          'oauth_version': OAUTH_VERSION
-        }
-      };
-
-      var accessor = {
-        consumerSecret: IMGUR_APP_SECRET,
-        tokenSecret: user.accessTokenSecret
-      };
-
-      var header = Imgur.getAuthorizationHeader(message, accessor);
-      ajax({
-        url: url,
-        method: 'GET',
-        headers: {
-          'Authorization': header
-        },
-        success: function(data) {
-          if (callback) {
-            user.id = data.account.url;
-            user.name = data.account.url;
-            callback('success', user);
-          }
-        },
-        status: {
-          others: function(data) {
-            callback('failure', 'failed_to_get_user_info');
-          }
-        }
-      });
-    },
-
-    upload: function(user, caption, imageData, callback) {
-      caption = encodeURIComponent(caption);
-      var message = {
-        action: IMGUR_PHOTO_UPLOAD_URL,
-        method: 'POST',
-        parameters: {
-          'oauth_consumer_key': IMGUR_APP_KEY,
-          'oauth_token': user.accessToken,
-          'oauth_signature_method': OAUTH_SIGNATURE_METHOD,
-          'oauth_version': OAUTH_VERSION
-        }
-      };
-      var accessor = {
-        consumerSecret: IMGUR_APP_SECRET,
-        tokenSecret: user.accessTokenSecret
-      };
-      var header = Imgur.getAuthorizationHeader(message, accessor);
-
-      var binaryData = {
-        boundary: MULTIPART_FORMDATA_BOUNDARY,
-        name: 'image',
-        value: 'screencapture.png',
-        data: imageData,
-        type: 'image/png'
-      };
-
-      ajax({
-        url: IMGUR_PHOTO_UPLOAD_URL,
-        method: 'POST',
-        multipartData: binaryData,
-        headers: {
-          'Authorization': header
-        },
-        success: function(response) {
-          callback('success', response.images.links.original);
-        },
-        status: {
-          others: function(err, statusCode) {
-            if (statusCode == 401) {
-              callback('failure', 'bad_access_token');
-            } else {
-              callback('failure', 'failed_to_upload_image');
-            };
-          }
-        }
-      });
-    },
-
-    getPhotoLink: function(user, photoLink, callback) {
-      callback('success', photoLink);
-    },
-
-    logout: function(callback) {
-      ajax({
-        url: IMGUR_LOGOUT_URL,
-        success: function() {
-          callback();
-        }
-      });
-    }
-  };
-})();
\ No newline at end of file
diff --git a/src/js/oauth.js b/src/js/oauth.js
deleted file mode 100644
index 85b2785..0000000
--- a/src/js/oauth.js
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright 2008 Netflix, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Here's some JavaScript software for implementing OAuth.
-
-   This isn't as useful as you might hope.  OAuth is based around
-   allowing tools and websites to talk to each other.  However,
-   JavaScript running in web browsers is hampered by security
-   restrictions that prevent code running on one website from
-   accessing data stored or served on another.
-
-   Before you start hacking, make sure you understand the limitations
-   posed by cross-domain XMLHttpRequest.
-
-   On the bright side, some platforms use JavaScript as their
-   language, but enable the programmer to access other web sites.
-   Examples include Google Gadgets, and Microsoft Vista Sidebar.
-   For those platforms, this library should come in handy.
-*/
-
-// The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by
-// http://pajhome.org.uk/crypt/md5/sha1.js
-
-/* An OAuth message is represented as an object like this:
-   {method: "GET", action: "http://server.com/path", parameters: ...}
-
-   The parameters may be either a map {name: value, name2: value2}
-   or an Array of name-value pairs [[name, value], [name2, value2]].
-   The latter representation is more powerful: it supports parameters
-   in a specific sequence, or several parameters with the same name;
-   for example [["a", 1], ["b", 2], ["a", 3]].
-
-   Parameter names and values are NOT percent-encoded in an object.
-   They must be encoded before transmission and decoded after reception.
-   For example, this message object:
-   {method: "GET", action: "http://server/path", parameters: {p: "x y"}}
-   ... can be transmitted as an HTTP request that begins:
-   GET /path?p=x%20y HTTP/1.0
-   (This isn't a valid OAuth request, since it lacks a signature etc.)
-   Note that the object "x y" is transmitted as x%20y.  To encode
-   parameters, you can call OAuth.addToURL, OAuth.formEncode or
-   OAuth.getAuthorization.
-
-   This message object model harmonizes with the browser object model for
-   input elements of an form, whose value property isn't percent encoded.
-   The browser encodes each value before transmitting it. For example,
-   see consumer.setInputs in example/consumer.js.
- */
-
-/* This script needs to know what time it is. By default, it uses the local
-   clock (new Date), which is apt to be inaccurate in browsers. To do
-   better, you can load this script from a URL whose query string contains
-   an oauth_timestamp parameter, whose value is a current Unix timestamp.
-   For example, when generating the enclosing document using PHP:
-
-   <script src="oauth.js?oauth_timestamp=<?=time()?>" ...
-
-   Another option is to call OAuth.correctTimestamp with a Unix timestamp.
- */
-
-var OAuth; if (OAuth == null) OAuth = {};
-
-OAuth.setProperties = function setProperties(into, from) {
-    if (into != null && from != null) {
-        for (var key in from) {
-            into[key] = from[key];
-        }
-    }
-    return into;
-}
-
-OAuth.setProperties(OAuth, // utility functions
-{
-    percentEncode: function percentEncode(s) {
-        if (s == null) {
-            return "";
-        }
-        if (s instanceof Array) {
-            var e = "";
-            for (var i = 0; i < s.length; ++s) {
-                if (e != "") e += '&';
-                e += OAuth.percentEncode(s[i]);
-            }
-            return e;
-        }
-        s = encodeURIComponent(s);
-        // Now replace the values which encodeURIComponent doesn't do
-        // encodeURIComponent ignores: - _ . ! ~ * ' ( )
-        // OAuth dictates the only ones you can ignore are: - _ . ~
-        // Source: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent
-        s = s.replace(/\!/g, "%21");
-        s = s.replace(/\*/g, "%2A");
-        s = s.replace(/\'/g, "%27");
-        s = s.replace(/\(/g, "%28");
-        s = s.replace(/\)/g, "%29");
-        return s;
-    }
-,
-    decodePercent: function decodePercent(s) {
-        if (s != null) {
-            // Handle application/x-www-form-urlencoded, which is defined by
-            // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
-            s = s.replace(/\+/g, " ");
-        }
-        return decodeURIComponent(s);
-    }
-,
-    /** Convert the given parameters to an Array of name-value pairs. */
-    getParameterList: function getParameterList(parameters) {
-        if (parameters == null) {
-            return [];
-        }
-        if (typeof parameters != "object") {
-            return OAuth.decodeForm(parameters + "");
-        }
-        if (parameters instanceof Array) {
-            return parameters;
-        }
-        var list = [];
-        for (var p in parameters) {
-            list.push([p, parameters[p]]);
-        }
-        return list;
-    }
-,
-    /** Convert the given parameters to a map from name to value. */
-    getParameterMap: function getParameterMap(parameters) {
-        if (parameters == null) {
-            return {};
-        }
-        if (typeof parameters != "object") {
-            return OAuth.getParameterMap(OAuth.decodeForm(parameters + ""));
-        }
-        if (parameters instanceof Array) {
-            var map = {};
-            for (var p = 0; p < parameters.length; ++p) {
-                var key = parameters[p][0];
-                if (map[key] === undefined) { // first value wins
-                    map[key] = parameters[p][1];
-                }
-            }
-            return map;
-        }
-        return parameters;
-    }
-,
-    getParameter: function getParameter(parameters, name) {
-        if (parameters instanceof Array) {
-            for (var p = 0; p < parameters.length; ++p) {
-                if (parameters[p][0] == name) {
-                    return parameters[p][1]; // first value wins
-                }
-            }
-        } else {
-            return OAuth.getParameterMap(parameters)[name];
-        }
-        return null;
-    }
-,
-    formEncode: function formEncode(parameters) {
-        var form = "";
-        var list = OAuth.getParameterList(parameters);
-        for (var p = 0; p < list.length; ++p) {
-            var value = list[p][1];
-            if (value == null) value = "";
-            if (form != "") form += '&';
-            form += OAuth.percentEncode(list[p][0])
-              +'='+ OAuth.percentEncode(value);
-        }
-        return form;
-    }
-,
-    decodeForm: function decodeForm(form) {
-        var list = [];
-        var nvps = form.split('&');
-        for (var n = 0; n < nvps.length; ++n) {
-            var nvp = nvps[n];
-            if (nvp == "") {
-                continue;
-            }
-            var equals = nvp.indexOf('=');
-            var name;
-            var value;
-            if (equals < 0) {
-                name = OAuth.decodePercent(nvp);
-                value = null;
-            } else {
-                name = OAuth.decodePercent(nvp.substring(0, equals));
-                value = OAuth.decodePercent(nvp.substring(equals + 1));
-            }
-            list.push([name, value]);
-        }
-        return list;
-    }
-,
-    setParameter: function setParameter(message, name, value) {
-        var parameters = message.parameters;
-        if (parameters instanceof Array) {
-            for (var p = 0; p < parameters.length; ++p) {
-                if (parameters[p][0] == name) {
-                    if (value === undefined) {
-                        parameters.splice(p, 1);
-                    } else {
-                        parameters[p][1] = value;
-                        value = undefined;
-                    }
-                }
-            }
-            if (value !== undefined) {
-                parameters.push([name, value]);
-            }
-        } else {
-            parameters = OAuth.getParameterMap(parameters);
-            parameters[name] = value;
-            message.parameters = parameters;
-        }
-    }
-,
-    setParameters: function setParameters(message, parameters) {
-        var list = OAuth.getParameterList(parameters);
-        for (var i = 0; i < list.length; ++i) {
-            OAuth.setParameter(message, list[i][0], list[i][1]);
-        }
-    }
-,
-    /** Fill in parameters to help construct a request message.
-        This function doesn't fill in every parameter.
-        The accessor object should be like:
-        {consumerKey:'foo', consumerSecret:'bar', accessorSecret:'nurn', token:'krelm', tokenSecret:'blah'}
-        The accessorSecret property is optional.
-     */
-    completeRequest: function completeRequest(message, accessor) {
-        if (message.method == null) {
-            message.method = "GET";
-        }
-        var map = OAuth.getParameterMap(message.parameters);
-        if (map.oauth_consumer_key == null) {
-            OAuth.setParameter(message, "oauth_consumer_key", accessor.consumerKey || "");
-        }
-        if (map.oauth_token == null && accessor.token != null) {
-            OAuth.setParameter(message, "oauth_token", accessor.token);
-        }
-        if (map.oauth_version == null) {
-            OAuth.setParameter(message, "oauth_version", "1.0");
-        }
-        if (map.oauth_timestamp == null) {
-            OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
-        }
-        if (map.oauth_nonce == null) {
-            OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
-        }
-        OAuth.SignatureMethod.sign(message, accessor);
-    }
-,
-    setTimestampAndNonce: function setTimestampAndNonce(message) {
-        OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
-        OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
-    }
-,
-    addToURL: function addToURL(url, parameters) {
-        newURL = url;
-        if (parameters != null) {
-            var toAdd = OAuth.formEncode(parameters);
-            if (toAdd.length > 0) {
-                var q = url.indexOf('?');
-                if (q < 0) newURL += '?';
-                else       newURL += '&';
-                newURL += toAdd;
-            }
-        }
-        return newURL;
-    }
-,
-    /** Construct the value of the Authorization header for an HTTP request. */
-    getAuthorizationHeader: function getAuthorizationHeader(realm, parameters) {
-        var header = 'OAuth realm="' + OAuth.percentEncode(realm) + '"';
-        var list = OAuth.getParameterList(parameters);
-        for (var p = 0; p < list.length; ++p) {
-            var parameter = list[p];
-            var name = parameter[0];
-            if (name.indexOf("oauth_") == 0) {
-                header += ',' + OAuth.percentEncode(name) + '="' + OAuth.percentEncode(parameter[1]) + '"';
-            }
-        }
-        return header;
-    }
-,
-    /** Correct the time using a parameter from the URL from which the last script was loaded. */
-    correctTimestampFromSrc: function correctTimestampFromSrc(parameterName) {
-        parameterName = parameterName || "oauth_timestamp";
-        var scripts = document.getElementsByTagName('script');
-        if (scripts == null || !scripts.length) return;
-        var src = scripts[scripts.length-1].src;
-        if (!src) return;
-        var q = src.indexOf("?");
-        if (q < 0) return;
-        parameters = OAuth.getParameterMap(OAuth.decodeForm(src.substring(q+1)));
-        var t = parameters[parameterName];
-        if (t == null) return;
-        OAuth.correctTimestamp(t);
-    }
-,
-    /** Generate timestamps starting with the given value. */
-    correctTimestamp: function correctTimestamp(timestamp) {
-        OAuth.timeCorrectionMsec = (timestamp * 1000) - (new Date()).getTime();
-    }
-,
-    /** The difference between the correct time and my clock. */
-    timeCorrectionMsec: 0
-,
-    timestamp: function timestamp() {
-        var t = (new Date()).getTime() + OAuth.timeCorrectionMsec;
-        return Math.floor(t / 1000);
-    }
-,
-    nonce: function nonce(length) {
-        var chars = OAuth.nonce.CHARS;
-        var result = "";
-        for (var i = 0; i < length; ++i) {
-            var rnum = Math.floor(Math.random() * chars.length);
-            result += chars.substring(rnum, rnum+1);
-        }
-        return result;
-    }
-});
-
-OAuth.nonce.CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
-
-/** Define a constructor function,
-    without causing trouble to anyone who was using it as a namespace.
-    That is, if parent[name] already existed and had properties,
-    copy those properties into the new constructor.
- */
-OAuth.declareClass = function declareClass(parent, name, newConstructor) {
-    var previous = parent[name];
-    parent[name] = newConstructor;
-    if (newConstructor != null && previous != null) {
-        for (var key in previous) {
-            if (key != "prototype") {
-                newConstructor[key] = previous[key];
-            }
-        }
-    }
-    return newConstructor;
-}
-
-/** An abstract algorithm for signing messages. */
-OAuth.declareClass(OAuth, "SignatureMethod", function OAuthSignatureMethod(){});
-
-OAuth.setProperties(OAuth.SignatureMethod.prototype, // instance members
-{
-    /** Add a signature to the message. */
-    sign: function sign(message) {
-        var baseString = OAuth.SignatureMethod.getBaseString(message);
-        var signature = this.getSignature(baseString);
-        OAuth.setParameter(message, "oauth_signature", signature);
-        return signature; // just in case someone's interested
-    }
-,
-    /** Set the key string for signing. */
-    initialize: function initialize(name, accessor) {
-        var consumerSecret;
-        if (accessor.accessorSecret != null
-            && name.length > 9
-            && name.substring(name.length-9) == "-Accessor")
-        {
-            consumerSecret = accessor.accessorSecret;
-        } else {
-            consumerSecret = accessor.consumerSecret;
-        }
-        this.key = OAuth.percentEncode(consumerSecret)
-             +"&"+ OAuth.percentEncode(accessor.tokenSecret);
-    }
-});
-
-/* SignatureMethod expects an accessor object to be like this:
-   {tokenSecret: "lakjsdflkj...", consumerSecret: "QOUEWRI..", accessorSecret: "xcmvzc..."}
-   The accessorSecret property is optional.
- */
-// Class members:
-OAuth.setProperties(OAuth.SignatureMethod, // class members
-{
-    sign: function sign(message, accessor) {
-        var name = OAuth.getParameterMap(message.parameters).oauth_signature_method;
-        if (name == null || name == "") {
-            name = "HMAC-SHA1";
-            OAuth.setParameter(message, "oauth_signature_method", name);
-        }
-        OAuth.SignatureMethod.newMethod(name, accessor).sign(message);
-    }
-,
-    /** Instantiate a SignatureMethod for the given method name. */
-    newMethod: function newMethod(name, accessor) {
-        var impl = OAuth.SignatureMethod.REGISTERED[name];
-        if (impl != null) {
-            var method = new impl();
-            method.initialize(name, accessor);
-            return method;
-        }
-        var err = new Error("signature_method_rejected");
-        var acceptable = "";
-        for (var r in OAuth.SignatureMethod.REGISTERED) {
-            if (acceptable != "") acceptable += '&';
-            acceptable += OAuth.percentEncode(r);
-        }
-        err.oauth_acceptable_signature_methods = acceptable;
-        throw err;
-    }
-,
-    /** A map from signature method name to constructor. */
-    REGISTERED : {}
-,
-    /** Subsequently, the given constructor will be used for the named methods.
-        The constructor will be called with no parameters.
-        The resulting object should usually implement getSignature(baseString).
-        You can easily define such a constructor by calling makeSubclass, below.
-     */
-    registerMethodClass: function registerMethodClass(names, classConstructor) {
-        for (var n = 0; n < names.length; ++n) {
-            OAuth.SignatureMethod.REGISTERED[names[n]] = classConstructor;
-        }
-    }
-,
-    /** Create a subclass of OAuth.SignatureMethod, with the given getSignature function. */
-    makeSubclass: function makeSubclass(getSignatureFunction) {
-        var superClass = OAuth.SignatureMethod;
-        var subClass = function() {
-            superClass.call(this);
-        };
-        subClass.prototype = new superClass();
-        // Delete instance variables from prototype:
-        // delete subclass.prototype... There aren't any.
-        subClass.prototype.getSignature = getSignatureFunction;
-        subClass.prototype.constructor = subClass;
-        return subClass;
-    }
-,
-    getBaseString: function getBaseString(message) {
-        var URL = message.action;
-        var q = URL.indexOf('?');
-        var parameters;
-        if (q < 0) {
-            parameters = message.parameters;
-        } else {
-            // Combine the URL query string with the other parameters:
-            parameters = OAuth.decodeForm(URL.substring(q + 1));
-            var toAdd = OAuth.getParameterList(message.parameters);
-            for (var a = 0; a < toAdd.length; ++a) {
-                parameters.push(toAdd[a]);
-            }
-        }
-        return OAuth.percentEncode(message.method.toUpperCase())
-         +'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeUrl(URL))
-         +'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeParameters(parameters));
-    }
-,
-    normalizeUrl: function normalizeUrl(url) {
-        var uri = OAuth.SignatureMethod.parseUri(url);
-        var scheme = uri.protocol.toLowerCase();
-        var authority = uri.authority.toLowerCase();
-        var dropPort = (scheme == "http" && uri.port == 80)
-                    || (scheme == "https" && uri.port == 443);
-        if (dropPort) {
-            // find the last : in the authority
-            var index = authority.lastIndexOf(":");
-            if (index >= 0) {
-                authority = authority.substring(0, index);
-            }
-        }
-        var path = uri.path;
-        if (!path) {
-            path = "/"; // conforms to RFC 2616 section 3.2.2
-        }
-        // we know that there is no query and no fragment here.
-        return scheme + "://" + authority + path;
-    }
-,
-    parseUri: function parseUri (str) {
-        /* This function was adapted from parseUri 1.2.1
-           http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
-         */
-        var o = {key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
-                 parser: {strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ }};
-        var m = o.parser.strict.exec(str);
-        var uri = {};
-        var i = 14;
-        while (i--) uri[o.key[i]] = m[i] || "";
-        return uri;
-    }
-,
-    normalizeParameters: function normalizeParameters(parameters) {
-        if (parameters == null) {
-            return "";
-        }
-        var list = OAuth.getParameterList(parameters);
-        var sortable = [];
-        for (var p = 0; p < list.length; ++p) {
-            var nvp = list[p];
-            if (nvp[0] != "oauth_signature") {
-                sortable.push([ OAuth.percentEncode(nvp[0])
-                              + " " // because it comes before any character that can appear in a percentEncoded string.
-                              + OAuth.percentEncode(nvp[1])
-                              , nvp]);
-            }
-        }
-        sortable.sort(function(a,b) {
-                          if (a[0] < b[0]) return  -1;
-                          if (a[0] > b[0]) return 1;
-                          return 0;
-                      });
-        var sorted = [];
-        for (var s = 0; s < sortable.length; ++s) {
-            sorted.push(sortable[s][1]);
-        }
-        return OAuth.formEncode(sorted);
-    }
-});
-
-OAuth.SignatureMethod.registerMethodClass(["PLAINTEXT", "PLAINTEXT-Accessor"],
-    OAuth.SignatureMethod.makeSubclass(
-        function getSignature(baseString) {
-            return this.key;
-        }
-    ));
-
-OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA1", "HMAC-SHA1-Accessor"],
-    OAuth.SignatureMethod.makeSubclass(
-        function getSignature(baseString) {
-            b64pad = '=';
-            var signature = b64_hmac_sha1(this.key, baseString);
-            return signature;
-        }
-    ));
-
-try {
-    OAuth.correctTimestampFromSrc();
-} catch(e) {
-}
diff --git a/src/js/options.js b/src/js/options.js
index 9d61498..bbbce70 100644
--- a/src/js/options.js
+++ b/src/js/options.js
@@ -19,15 +19,12 @@
   i18nReplace('screenshootQualitySetting', 'quality_setting');
   i18nReplace('lossyScreenShot', 'lossy');
   i18nReplace('losslessScreenShot', 'lossless');
-  i18nReplace('shorcutSetting', 'shortcut_setting');
-  i18nReplace('settingShortcutText', 'shortcutsetting_text');
   if (isHighVersion()) {
     $('lossyScreenShot').innerText += ' (JPEG)';
     $('losslessScreenShot').innerText += ' (PNG)';
   }
   $('saveAndClose').addEventListener('click', saveAndClose);
   initScreenCaptureQuality();
-  HotKeySetting.setup();
 }
 
 function save() {
@@ -35,7 +32,7 @@
       $('lossy').checked ? 'jpeg' : '' ||
       $('lossless').checked ? 'png' : '';
 
-  return HotKeySetting.save();
+  return true;
 }
 
 function saveAndClose() {
@@ -59,107 +56,6 @@
   UI.addStyleSheet('./i18n_styles/en_options.css');
 }
 
-var HotKeySetting = (function() {
-  const CHAR_CODE_OF_AT = 64;
-  const CHAR_CODE_OF_A = 65;
-  const CHAR_CODE_OF_Z = 90;
-  var hotKeySelection = null;
-
-  var hotkey = {
-    setup: function() {
-      hotKeySelection = document.querySelectorAll('#hot-key-setting select');
-      // i18n.
-      $('area-capture-text').innerText =
-        chrome.i18n.getMessage('capture_area');
-      $('viewport-capture-text').innerText =
-        chrome.i18n.getMessage('capture_window');
-      $('full-page-capture-text').innerText =
-        chrome.i18n.getMessage('capture_webpage');
-      //$('screen-capture-text').innerText = chrome.i18n.getMessage('capture_screen');
-
-      for (var i = 0; i < hotKeySelection.length; i++) {
-        hotKeySelection[i].add(new Option('--', '@'));
-        for (var j = CHAR_CODE_OF_A; j <= CHAR_CODE_OF_Z; j++) {
-          var value = String.fromCharCode(j);
-          var option = new Option(value, value);
-          hotKeySelection[i].add(option);
-        }
-      }
-
-      $('area-capture-hot-key').selectedIndex =
-        HotKey.getCharCode('area') - CHAR_CODE_OF_AT;
-      $('viewport-capture-hot-key').selectedIndex =
-        HotKey.getCharCode('viewport') - CHAR_CODE_OF_AT;
-      $('full-page-capture-hot-key').selectedIndex =
-        HotKey.getCharCode('fullpage') - CHAR_CODE_OF_AT;
-      $('screen-capture-hot-key').selectedIndex =
-        HotKey.getCharCode('screen') - CHAR_CODE_OF_AT;
-
-      $('settingShortcut').addEventListener('click', function() {
-        hotkey.setState(this.checked);
-      }, false);
-
-      hotkey.setState(HotKey.isEnabled());
-    },
-
-    validate: function() {
-      var hotKeyLength =
-        Array.prototype.filter.call(hotKeySelection,
-            function (element) {
-              return element.value != '@'
-            }
-        ).length;
-      if (hotKeyLength != 0) {
-        var validateMap = {};
-        validateMap[hotKeySelection[0].value] = true;
-        validateMap[hotKeySelection[1].value] = true;
-        validateMap[hotKeySelection[2].value] = true;
-        if (hotKeyLength > 3 && hotKeySelection[3].value != '@') {
-          hotKeyLength -= 1;
-        }
-
-        if (Object.keys(validateMap).length < hotKeyLength) {
-          ErrorInfo.show('hot_key_conflict');
-          return false;
-        }
-      }
-      ErrorInfo.hide();
-      return true;
-    },
-
-    save: function() {
-      var result = true;
-      if ($('settingShortcut').checked) {
-        if (this.validate()) {
-          HotKey.enable();
-          HotKey.set('area', $('area-capture-hot-key').value);
-          HotKey.set('viewport', $('viewport-capture-hot-key').value);
-          HotKey.set('fullpage', $('full-page-capture-hot-key').value);
-        } else {
-          result = false;
-        }
-      } else {
-        HotKey.disable(bg);
-      }
-      return result;
-    },
-
-    setState: function(enabled) {
-      $('settingShortcut').checked = enabled;
-      UI.setStyle($('hot-key-setting'), 'color', enabled ? '' : '#6d6d6d');
-      for (var i = 0; i < hotKeySelection.length; i++) {
-        hotKeySelection[i].disabled = !enabled;
-      }
-      ErrorInfo.hide();
-    },
-
-    focusScreenCapture: function() {
-      $('screen-capture-hot-key').focus();
-    }
-  };
-  return hotkey;
-})();
-
 var ErrorInfo = (function() {
   return {
     show: function(msgKey) {
diff --git a/src/js/page.js b/src/js/page.js
index 2c5702d..9ca2463 100644
--- a/src/js/page.js
+++ b/src/js/page.js
@@ -241,15 +241,7 @@
   },
 
   getOriginalViewPortWidth: function() {
-    chrome.extension.sendMessage({ msg: 'original_view_port_width'},
-      function(originalViewPortWidth) {
-        if (originalViewPortWidth) {
-          page.originalViewPortWidth = page.hasScrollBar('y') ?
-            originalViewPortWidth - page.defaultScrollBarWidth : originalViewPortWidth;
-        } else {
-          page.originalViewPortWidth = document.documentElement.clientWidth;
-        }
-      });
+    page.originalViewPortWidth = document.documentElement.clientWidth;
   },
   
   calculateSizeAfterZooming: function(originalSize) {
@@ -895,13 +887,3 @@
   // Reget original width of view port if browser window resized or page zoomed.
   page.getOriginalViewPortWidth();
 }, false);
-
-// Send page url for retriving and parsing access token for facebook and picasa.
-var message = {
-  msg: 'url_for_access_token',
-  url: window.location.href
-}
-if (window.location.href.indexOf('https://api.weibo.com/oauth2/default.html') == 0) {
-  message.siteId = 'sina'
-}
-page.sendMessage(message);
diff --git a/src/js/picasa.js b/src/js/picasa.js
deleted file mode 100644
index e6343a8..0000000
--- a/src/js/picasa.js
+++ /dev/null
@@ -1,237 +0,0 @@
-(function() {
-  const ALBUM_NAME = 'Screen Capture';
-  const CLIENT_ID = '368358534491.apps.googleusercontent.com';
-  const AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
-  const REDIRECT_URI = 'https://picasaweb.google.com';
-  const SCOPE = 'https://picasaweb.google.com/data/';
-  const RESPONSE_TYPE = 'token';
-  const ALBUM_URL = 'https://picasaweb.google.com/data/feed/api/user/' +
-    'default';
-  const CREATE_ALBUM_URL = 'https://picasaweb.google.com/data/feed/api/user/' +
-    'default';
-  const UPLOAD_BASE_URL = 'https://picasaweb.google.com/data/feed/api/user/' +
-    'default/albumid/';
-  const LOGOUT_URL = 'https://picasaweb.google.com/bye?continue=' +
-    'https://www.google.com/accounts/Logout?continue=' +
-    'https://picasaweb.google.com';
-
-  // var picasa = window.Picasa = new Site('picasa');
-  var picasa = window.Picasa = {
-    siteId: 'picasa',
-    currentUserId: null,
-    redirectUrl: REDIRECT_URI,
-    accessTokenCallback: null,
-    
-    getAccessToken: function(callback) {
-      picasa.accessTokenCallback = callback;
-      var url = AUTH_URL + '?client_id=' + CLIENT_ID + '&redirect_uri=' +
-        REDIRECT_URI + '&scope=' + SCOPE + '&response_type=' + RESPONSE_TYPE;
-      chrome.tabs.create({ url: url});
-    },
-
-    parseRedirectUrl: function(url) {
-      var result = false;
-      if (url.indexOf(REDIRECT_URI) == 0) {
-        var hash = url.split('#')[1];
-        if (hash) {
-          var params = hash.split('&');
-          var paramMap = {};
-          params.forEach(function(param) {
-            paramMap[param.split('=')[0]] = param.split('=')[1];
-          });
-
-          var accessToken = paramMap['access_token'];
-          var expires = paramMap['expires_in'];
-          if (accessToken && expires) {
-            result = {
-              accessToken: accessToken,
-              expires: expires
-            };
-          } else {
-            result = 'bad_redirect_url'; // Should never happened.
-          }
-        } else {
-          var search = url.split('?')[1];
-          if (search == 'error=access_denied')
-            result = 'access_denied';
-        }
-      }
-      return result;
-    },
-    
-    isRedirectUrl: function(url) {
-      return picasa.parseRedirectUrl(url) != false;
-    },
-    
-    parseAccessToken: function(redirectUrl) {
-      var parsedResult = picasa.parseRedirectUrl(redirectUrl);
-      if (parsedResult && typeof parsedResult == 'object') {
-        var user = new User({
-          accessToken: parsedResult.accessToken,
-          expires: new Date().getTime() + parsedResult.expires * 1000
-        });
-        picasa.accessTokenCallback('success', user);
-      } else {
-        picasa.accessTokenCallback('failure', 'user_denied');
-      }
-      picasa.accessTokenCallback = null;
-    },
-    
-    getUserInfo: function(user, callback) {
-      ajax({
-        url: ALBUM_URL,
-        parameters: {
-          fields: 'title,gphoto:nickname,entry/title,entry/gphoto:id',
-          alt: 'json',
-          access_token: user.accessToken
-        },
-        success: function(res) {
-          var userId = res.feed.title.$t;
-          var userName = res.feed.gphoto$nickname.$t;
-          user.id = userId;
-          user.name = userName;
-          
-          var albums = res.feed.entry;
-          if (albums) {
-            var length = albums.length;
-
-            // Check if user has created album "Screen Capture".
-            for (var i = 0; i < length; i++) {
-              var albumName = albums[i].title.$t;
-              if (albumName == ALBUM_NAME) {
-                user.albumId = albums[i].gphoto$id.$t;
-                break;
-              }
-            }
-          }
-
-          // Create album "Screen Capture" and retrieve album id.
-          if (!user.albumId) {
-            picasa.createAlbum(user.accessToken, function(result,
-                                                          albumIdOrMessage) {
-              if (result == 'success') {
-                user.albumId = albumIdOrMessage;
-                callback('success', user);
-              } else {
-                callback('failure', albumIdOrMessage);
-              }
-            });
-          } else {
-            callback('success', user);
-          }
-        },
-        status: {
-          404: function() {
-            callback('failure', 'failed_to_get_user_info');
-          }
-        }
-      });
-    },
-
-    createAlbum: function(accessToken, callback) {
-      var data = '<entry xmlns="http://www.w3.org/2005/Atom" ' +
-        'xmlns:media="http://search.yahoo.com/mrss/" ' +
-        'xmlns:gphoto="http://schemas.google.com/photos/2007">' +
-        '<title type="text">' + ALBUM_NAME +
-        '</title><category scheme="http://schemas.google.com/g/2005#kind" ' +
-        'term="http://schemas.google.com/photos/2007#album"></category>' +
-        '</entry>';
-
-      ajax({
-        method: 'POST',
-        url: CREATE_ALBUM_URL,
-        parameters: {
-          alt: 'json'
-        },
-        data: data,
-        headers: {
-          'GData-Version': 2,
-          'Content-Type': 'application/atom+xml',
-          'Authorization': 'OAuth ' + accessToken
-        },
-        complete: function(statusCode, album) {
-          if (statusCode == 201) {
-            var albumId = album.entry.gphoto$id.$t;
-            callback('success', albumId);
-          } else {
-            callback('failure', 'failure_to_create_album')
-          }
-        }
-      });
-    },
-
-    upload: function(user, caption, imageData, callback) {
-      caption = ajax.convertEntityString(caption);
-      caption = ajax.encodeForBinary(caption);
-
-      var imageFile = new Date().getTime() + '.png';
-      var headers = {
-        'GData-Version': 2,
-        'Content-Type': 'multipart/related; boundary=' +
-          MULTIPART_FORMDATA_BOUNDARY,
-        'Authorization': 'OAuth ' + user.accessToken
-      };
-
-      var captionData = '<entry xmlns="http://www.w3.org/2005/Atom">' +
-        '<title>' + imageFile + '</title>' +
-        '<summary>' + caption + '</summary>' +
-        '<category scheme="http://schemas.google.com/g/2005#kind" ' +
-        'term="http://schemas.google.com/photos/2007#photo"/></entry>';
-
-      var dataPart1 = {
-        contentType: 'application/atom+xml',
-        data: captionData
-      };
-      var dataPart2 = {
-        contentType: 'image/png',
-        data: imageData
-      };
-      var multipartData = {
-        boundary: MULTIPART_FORMDATA_BOUNDARY,
-        dataList: [dataPart1, dataPart2]
-      };
-
-      ajax({
-        url: UPLOAD_BASE_URL + user.albumId + '?alt=json',
-        headers: headers,
-        multipartData: multipartData,
-        complete: function(statusCode, res) {
-          if (statusCode == 201) {
-            var link = res.entry.link;
-            callback('success', link);
-          } else {
-            var message = 'failed_to_upload_image';
-            if (statusCode == 403) {
-              // bad access token
-              message = 'bad_access_token';
-            } else if (statusCode == 404 && res == 'No album found.') {
-              // Invalid album id.
-              message = 'invalid_album_id'
-            }
-            callback('failure', message);
-          }
-        }
-      });
-    },
-
-    getPhotoLink: function(user, photolinks, callback) {
-      for (var i = 0; i < photolinks.length; i++) {
-        var link = photolinks[i];
-        if (link.type == 'text/html' &&
-            link.rel == 'http://schemas.google.com/photos/2007#canonical') {
-          callback('success', link.href);
-          break;
-        }
-      }
-    },
-
-    logout: function(callback) {
-      ajax({
-        url: LOGOUT_URL,
-        success: function() {
-          callback();
-        }
-      });
-    }
-  };
-})();
\ No newline at end of file
diff --git a/src/js/popup.js b/src/js/popup.js
index 3f5690f..2319055 100644
--- a/src/js/popup.js
+++ b/src/js/popup.js
@@ -65,17 +65,12 @@
   $('option').addEventListener('click', function () {
     chrome.tabs.create({ url: 'options.html'});
   }, false);
-  if (HotKey.isEnabled()) {
-    $('captureWindowShortcut').style.display = 'inline';
-    $('captureAreaShortcut').style.display = 'inline';
-    $('captureWebpageShortcut').style.display = 'inline';
-    document.body.style.minWidth = "190px"
-  } else {
-    $('captureWindowShortcut').style.display = 'none';
-    $('captureAreaShortcut').style.display = 'none';
-    $('captureWebpageShortcut').style.display = 'none';
-    document.body.style.minWidth = "140px";
-  }
+
+  $('captureWindowShortcut').style.display = 'none';
+  $('captureAreaShortcut').style.display = 'none';
+  $('captureWebpageShortcut').style.display = 'none';
+  document.body.style.minWidth = "140px";
+
   var isScriptLoad = false;
   chrome.tabs.getSelected(null, function(tab) {
     if (tab.url.indexOf('chrome') == 0 || tab.url.indexOf('about') == 0) {
@@ -140,17 +135,6 @@
   setTimeout(insertScript, 500);
 
   // Update hot key.
-  if (HotKey.get('area') != '@')
-    $('captureAreaShortcut').innerText = 'Ctrl+Alt+' + HotKey.get('area');
-  if (HotKey.get('viewport') != '@') {
-    $('captureWindowShortcut').innerText = 'Ctrl+Alt+' +
-        HotKey.get('viewport');
-  }
-  if (HotKey.get('fullpage') != '@') {
-    $('captureWebpageShortcut').innerText ='Ctrl+Alt+' +
-        HotKey.get('fullpage');
-  }
-
   $('captureSpecialPageItem').addEventListener('click', function(e) {
     toDo('capture_special_page');
   });
diff --git a/src/js/sha1.js b/src/js/sha1.js
deleted file mode 100644
index 1b55982..0000000
--- a/src/js/sha1.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
- * in FIPS PUB 180-1
- * Version 2.1a Copyright Paul Johnston 2000 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for details.
- */
-
-/*
- * Configurable variables. You may need to tweak these to be compatible with
- * the server-side, but the defaults work in most cases.
- */
-var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
-var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
-var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
-
-/*
- * These are the functions you'll usually want to call
- * They take string arguments and return either hex or base-64 encoded strings
- */
-function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
-function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
-function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
-function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
-function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
-function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
-
-/*
- * Perform a simple self-test to see if the VM is working
- */
-function sha1_vm_test()
-{
-  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
-}
-
-/*
- * Calculate the SHA-1 of an array of big-endian words, and a bit length
- */
-function core_sha1(x, len)
-{
-  /* append padding */
-  x[len >> 5] |= 0x80 << (24 - len % 32);
-  x[((len + 64 >> 9) << 4) + 15] = len;
-
-  var w = Array(80);
-  var a =  1732584193;
-  var b = -271733879;
-  var c = -1732584194;
-  var d =  271733878;
-  var e = -1009589776;
-
-  for(var i = 0; i < x.length; i += 16)
-  {
-    var olda = a;
-    var oldb = b;
-    var oldc = c;
-    var oldd = d;
-    var olde = e;
-
-    for(var j = 0; j < 80; j++)
-    {
-      if(j < 16) w[j] = x[i + j];
-      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
-      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
-                       safe_add(safe_add(e, w[j]), sha1_kt(j)));
-      e = d;
-      d = c;
-      c = rol(b, 30);
-      b = a;
-      a = t;
-    }
-
-    a = safe_add(a, olda);
-    b = safe_add(b, oldb);
-    c = safe_add(c, oldc);
-    d = safe_add(d, oldd);
-    e = safe_add(e, olde);
-  }
-  return Array(a, b, c, d, e);
-
-}
-
-/*
- * Perform the appropriate triplet combination function for the current
- * iteration
- */
-function sha1_ft(t, b, c, d)
-{
-  if(t < 20) return (b & c) | ((~b) & d);
-  if(t < 40) return b ^ c ^ d;
-  if(t < 60) return (b & c) | (b & d) | (c & d);
-  return b ^ c ^ d;
-}
-
-/*
- * Determine the appropriate additive constant for the current iteration
- */
-function sha1_kt(t)
-{
-  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
-         (t < 60) ? -1894007588 : -899497514;
-}
-
-/*
- * Calculate the HMAC-SHA1 of a key and some data
- */
-function core_hmac_sha1(key, data)
-{
-  var bkey = str2binb(key);
-  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
-
-  var ipad = Array(16), opad = Array(16);
-  for(var i = 0; i < 16; i++)
-  {
-    ipad[i] = bkey[i] ^ 0x36363636;
-    opad[i] = bkey[i] ^ 0x5C5C5C5C;
-  }
-
-  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
-  return core_sha1(opad.concat(hash), 512 + 160);
-}
-
-/*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
-function safe_add(x, y)
-{
-  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
-  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
-  return (msw << 16) | (lsw & 0xFFFF);
-}
-
-/*
- * Bitwise rotate a 32-bit number to the left.
- */
-function rol(num, cnt)
-{
-  return (num << cnt) | (num >>> (32 - cnt));
-}
-
-/*
- * Convert an 8-bit or 16-bit string to an array of big-endian words
- * In 8-bit function, characters >255 have their hi-byte silently ignored.
- */
-function str2binb(str)
-{
-  var bin = Array();
-  var mask = (1 << chrsz) - 1;
-  for(var i = 0; i < str.length * chrsz; i += chrsz)
-    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
-  return bin;
-}
-
-/*
- * Convert an array of big-endian words to a string
- */
-function binb2str(bin)
-{
-  var str = "";
-  var mask = (1 << chrsz) - 1;
-  for(var i = 0; i < bin.length * 32; i += chrsz)
-    str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
-  return str;
-}
-
-/*
- * Convert an array of big-endian words to a hex string.
- */
-function binb2hex(binarray)
-{
-  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
-  var str = "";
-  for(var i = 0; i < binarray.length * 4; i++)
-  {
-    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
-           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
-  }
-  return str;
-}
-
-/*
- * Convert an array of big-endian words to a base-64 string
- */
-function binb2b64(binarray)
-{
-  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-  var str = "";
-  for(var i = 0; i < binarray.length * 4; i += 3)
-  {
-    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)
-                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
-                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
-    for(var j = 0; j < 4; j++)
-    {
-      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
-      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
-    }
-  }
-  return str;
-}
diff --git a/src/js/shortcut.js b/src/js/shortcut.js
deleted file mode 100644
index 7959178..0000000
--- a/src/js/shortcut.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var shortcutKey = {
-
-  init: function() {
-    if (document.body.hasAttribute('screen_capture_injected')) {
-      return;
-    }
-    document.body.setAttribute('screen_capture_injected', true);
-    document.body.addEventListener('keydown', shortcutKey.handleShortcut,
-      false);
-  },
-
-  isThisPlatform: function(operationSystem) {
-    return navigator.userAgent.toLowerCase().indexOf(operationSystem) > -1;
-  },
-
-  handleShortcut: function (event) {
-    var isMac = shortcutKey.isThisPlatform('mac');
-    var keyCode = event.keyCode;
-    // Send compose key like Ctrl + Alt + alphabetical-key to background.
-    if ((event.ctrlKey && event.altKey && !isMac ||
-          event.metaKey && event.altKey && isMac) &&
-        keyCode > 64 && keyCode < 91) {
-      shortcutKey.sendMessage({
-        msg: 'capture_hot_key',
-        keyCode: keyCode
-      });
-    }
-  },
-
-  sendMessage: function(message) {
-    chrome.extension.sendMessage(message);
-  }
-};
-
-shortcutKey.init();
diff --git a/src/js/showimage.js b/src/js/showimage.js
index 294353d..b0d5f03 100644
--- a/src/js/showimage.js
+++ b/src/js/showimage.js
@@ -13,7 +13,6 @@
 function i18nReplace(id, messageKey) {
   return $(id).innerHTML = chrome.i18n.getMessage(messageKey);
 }
-UploadUI.init();
 
 var bg = chrome.extension.getBackgroundPage();
 var canvas = new Canvas();
@@ -503,6 +502,17 @@
     }
   },
 
+  save: function() {
+    photoshop.draw();
+    var formatParam  = localStorage.screenshootQuality || 'png';
+    var dataUrl;
+    var isJpeg = formatParam == 'jpeg';
+    $('canvas').toBlob(function(blob) {
+      saveAs(blob, chrome.extension.getBackgroundPage().screenshot.screenshotName+".png");
+    }, 'image/' + (isJpeg ? 'jpeg' : 'png'), (isJpeg ? 0.5 : null));
+    photoshop.finish();
+  },
+
   drawLineOnMaskCanvas: function(startX, startY, endX, endY, type, layerId) {
     var ctx = $('mask-canvas').getContext('2d');
     ctx.clearRect(0, 0, $('mask-canvas').width, $('mask-canvas').height);
@@ -809,16 +819,5 @@
     'selectstart', function f(e) { return false });
 $('mask-canvas').addEventListener(
     'selectstart', function f(e) { return false });
+$('btnSave').addEventListener('click', photoshop.save);
 $('btnClose').addEventListener('click', photoshop.closeCurrentTab);
-$('uploadAccountList').addEventListener('click', function(e) {
-  var target = e.target;
-  var classList = Array.prototype.slice.call(target.classList)
-  if (classList.indexOf('accountName') >= 0) {
-    var site = target.dataset.site;
-    var userId = target.dataset.userId;
-    UploadUI.upload(site, userId);
-  } else if (classList.indexOf('deleteBtn') >= 0) {
-    var accountId = target.dataset.accountId;
-    UploadUI.deleteAccountItem(accountId);
-  }
-});
diff --git a/src/js/sina_microblog.js b/src/js/sina_microblog.js
deleted file mode 100644
index 18b153b..0000000
--- a/src/js/sina_microblog.js
+++ /dev/null
@@ -1,122 +0,0 @@
-const APPKEY = '1350884563';
-const AUTHORIZE_URL = 'https://api.weibo.com/oauth2/authorize';
-const REDIRECT_URL = 'https://api.weibo.com/oauth2/default.html'
-const SINA_USER_INFO_URL = 'https://api.weibo.com/2/users/show.json';
-const SINA_PHOTO_UPLOAD_URL = 'https://upload.api.weibo.com/2/statuses/upload.json';
-const SINA_LOGOUT_URL = 'https://api.weibo.com/2/account/end_session.json';
-
-var SinaMicroblog = {
-  siteId: 'sina',
-  currentUserId: null,
-  accessTokenCallback: null,
-
-  isRedirectUrl: function() {},
-
-  getAccessToken: function(callback) {
-    SinaMicroblog.accessTokenCallback = callback;
-    var url = AUTHORIZE_URL + '?client_id=' + APPKEY +
-      '&redirect_uri=' + REDIRECT_URL + '&response_type=token';
-    chrome.tabs.create({url: url});
-  },
-  
-  parseAccessToken: function(url) {
-    var result = 'failure';
-    var msgOrUser = 'sina_failed_to_get_access_token';
-    var hash = url.split('#')[1];
-    if (hash && typeof hash == 'string') {
-      var keyValues = hash.split('&');
-      var response = {};
-
-      for (var keyValue, i = 0, l = keyValues.length; i < l; i++) {
-        keyValue = keyValues[i].split('=');
-        response[keyValue[0]] = keyValue[1];
-      }
-
-      if (!response.error && response.access_token && response.uid) {
-        result = 'success';
-        msgOrUser = new User({
-          id: response.uid,
-          accessToken: response.access_token
-        });
-      }
-    }
-
-    SinaMicroblog.accessTokenCallback(result, msgOrUser);
-    SinaMicroblog.accessTokenCallback = null;
-  },
-
-  getUserInfo: function(user, callback) {
-    ajax({
-      url: SINA_USER_INFO_URL,
-      parameters: {
-        access_token: user.accessToken,
-        uid: user.id
-      },
-      success: function(data) {
-        if (callback) {
-          user.name = data.screen_name;
-          callback('success', user);
-        }
-      },
-      status: {
-        others: function(data) {
-          callback('failure', 'failed_to_get_user_info');
-        }
-      }
-    });
-  },
-
-  upload: function(user, caption, imageData, callback) {
-    caption = encodeURIComponent(caption);
-    var params = {
-      access_token: user.accessToken,
-      status: caption
-    };
-    var binaryData = {
-      boundary: MULTIPART_FORMDATA_BOUNDARY,
-      name: 'pic',
-      value: 'test.png',
-      data: imageData,
-      type: 'image/png'
-    };
-    
-    ajax({
-      url: SINA_PHOTO_UPLOAD_URL,
-      parameters: params,
-      multipartData: binaryData,
-      success: function(microblog) {
-        callback('success', microblog.id);
-      },
-      status: {
-        others: function(res) {
-          var message = 'failed_to_upload_image';
-          var errorCode = res.error_code;
-          var invalidAccessTokenCodes = 
-            [21332, 21314, 21315, 21316, 21317, 21319, 21327];
-          if (invalidAccessTokenCodes.indexOf(errorCode) >= 0) {
-            message = 'bad_access_token';
-          }
-          callback('failure', message);
-        }
-      }
-    });
-  },
-
-  getPhotoLink: function(user, microblogId, callback) {
-    var photoLink = 'http://weibo.com/' + user.id + '/profile';
-    callback('success', photoLink);
-  },
-  
-  logout: function(callback) {
-    var params = {source: APPKEY};
-    ajax({
-      url: SINA_LOGOUT_URL,
-      parameters: params,
-      complete: function(statusCode, data) {
-        // Response status 403 means no user signed in
-        if ((statusCode == 200 || statusCode == 403) && callback)
-          callback(data);
-      }
-    });
-  }
-};
\ No newline at end of file
diff --git a/src/js/site.js b/src/js/site.js
deleted file mode 100644
index 6bb43f8..0000000
--- a/src/js/site.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var Site = function(id) {
-  this.siteId = id;
-};
-
-Site.prototype = {
-  /**
-   * Get access token by user's authorization.
-   * @param {Function} callback call-back function, parameters:
-   *   {String} result, success or failure; {User|String} user with access
-   *   token, etc. or error message.
-   */
-  getAccessToken: function(callback) {},
-
-  /**
-   * Check if the url is redirect url for retrieving access token of current
-   * site.
-   * @param {String} url
-   * @return {Boolean} result
-   */
-  isRedirectUrl: function(url) {},
-
-  /**
-   * Parse and get access token from redirect url, then call call-back function
-   * of passed by calling getAccessToken method with access token.
-   * @param {String} url
-   */
-  parseAccessToken: function(url) {},
-
-  /**
-   * Get user information.
-   * @param {User} user
-   * @param {Function} callback call-back function, parameters:
-   *   {String} result, success or failure; {User|String} user with user id,
-   *   user name, etc. or error message.
-   */
-  getUserInfo: function(user, callback) {},
-
-  /**
-   * Upload image.
-   * @param {User} user user data with access token, etc.
-   * @param {String} caption image description
-   * @param {String} imageData binary image data
-   * @param callback  call-back function, parameters:
-   *   {String} result, success or failure; {String} photo id or error message.
-   */
-  upload: function(user, caption, imageData, callback) {},
-
-  /**
-   * Get photo link.
-   * @param {User} user user data with id, access token, etc.
-   * @param {String} photoId
-   * @param {Function} callback call-back function, parameters:
-   *   {String} result, success or failure; {String} photo link or error
-   *   message.
-   */
-  getPhotoLink: function(user, photoId, callback) {},
-
-  /**
-   * Log out current signed in user.
-   * @param callback
-   */
-  logout: function(callback) {}
-};
\ No newline at end of file
diff --git a/src/js/upload_ui.js b/src/js/upload_ui.js
deleted file mode 100644
index 5b073f5..0000000
--- a/src/js/upload_ui.js
+++ /dev/null
@@ -1,487 +0,0 @@
-const CURRENT_LOCALE = chrome.i18n.getMessage('@@ui_locale');
-const MULTIPART_FORMDATA_BOUNDARY = 'Google_Chrome_Screen_Capture';
-const HIDE_ERROR_INFO_DELAY_TIME = 5000;
-
-var UploadUI = {
-  currentSite: '',
-  uploading: false,
-  sites: {},
-
-  registerSite: function(id, siteObject) {
-    this.sites[id] = siteObject;
-  },
-
-  getSiteObject: function(id) {
-    return this.sites[id];
-  },
-
-  setUploading: function(state) {
-    UploadUI.uploading = state;
-  },
-
-  init: function() {
-    // Register supported site for image sharing.
-    UploadUI.registerSite(SinaMicroblog.siteId, SinaMicroblog);
-    UploadUI.registerSite(Facebook.siteId, Facebook);
-    UploadUI.registerSite(Picasa.siteId, Picasa);
-    UploadUI.registerSite(Imgur.siteId, Imgur);
-
-    // Import style sheet for current locale
-    if (CURRENT_LOCALE == 'zh_CN')
-      UI.addStyleSheet('./i18n_styles/zh_CN_upload_image.css');
-    else
-      UI.addStyleSheet('./i18n_styles/en_US_upload_image.css');
-
-    // Get i18n message
-    i18nReplace('shareToSinaMicroblogText', SinaMicroblog.siteId +
-      '_upload_header');
-    i18nReplace('shareToFacebookText', Facebook.siteId + '_upload_header');
-    i18nReplace('shareToPicasaText', Picasa.siteId + '_upload_header');
-    i18nReplace('lastStep', 'return_to_site_selection');
-    i18nReplace('closeUploadWrapper', 'close_upload_wrapper');
-    i18nReplace('imageCaptionText', 'image_caption');
-    i18nReplace('photoSizeTip', 'photo_size_tip');
-    i18nReplace('shareToImgurText', Imgur.siteId + '_upload_header');
-    $('requiredFlag').setAttribute('title',
-      chrome.i18n.getMessage('invalid_caption'));
-
-    // Add event listeners
-    //$('btnUpload').addEventListener('click', UploadUI.showUploadWrapper, false);
-    $('btnSave').addEventListener('click', UploadUI.saveImage, false);
-    $('closeUploadWrapper').addEventListener('click',
-      UploadUI.hideUploadWrapper, false);
-
-    $('picasaBtn').addEventListener('click', function() {
-      UploadUI.showUploadContentWrapper(Picasa.siteId);
-    });
-    $('facebookBtn').addEventListener('click', function() {
-      UploadUI.showUploadContentWrapper(Facebook.siteId);
-    }, false);
-    $('sinaMicroblogBtn').addEventListener('click', function() {
-      UploadUI.showUploadContentWrapper(SinaMicroblog.siteId);
-    }, false);
-    $('imgurBtn').addEventListener('click', function() {
-      UploadUI.showUploadContentWrapper(Imgur.siteId);
-    }, false);
-    $('shareToOtherAccount').addEventListener('click', function() {
-      var currentSite = UploadUI.currentSite;
-
-      // Validate image description first
-      if (UploadUI.validatePhotoDescription(currentSite)) {
-        var callback = function() {
-          var authenticationTip =
-            chrome.i18n.getMessage('user_authentication_tip');
-          UploadUI.showAuthenticationProgress(authenticationTip);
-          UploadUI.getAccessToken(currentSite);
-        };
-        var users = Account.getUsers(currentSite);
-        var numberOfUsers = Object.keys(users).length;
-
-        // Logout when user has authenticated app
-        if (numberOfUsers) {
-          var logoutTip = chrome.i18n.getMessage('user_logout_tip');
-          UploadUI.showAuthenticationProgress(logoutTip);
-          var site = UploadUI.getSiteObject(currentSite);
-          site.logout(callback);
-        } else {
-          callback();
-        }
-      }
-    }, false);
-    $('lastStep').addEventListener('click', UploadUI.showUploadSitesWrapper,
-      false);
-  },
-
-  showUploadWrapper: function() {
-    var uploadWrapper = $('uploadWrapper');
-    UI.show(uploadWrapper);
-
-    // Reset upload wrapper position
-    var viewportWidth = window.innerWidth;
-    var viewportHeight = window.innerHeight;
-    var wrapperWidth = uploadWrapper.offsetWidth;
-    var wrapperHeight = uploadWrapper.offsetHeight;
-
-    var left = (viewportWidth - wrapperWidth) / 2;
-    var top = (viewportHeight - wrapperHeight) / 3;
-    left = left < 0 ? 0 : left;
-    top = top < 0 ? 0 : top;
-
-    var scrollTop = document.body.scrollTop;
-    var scrollLeft = document.body.scrollLeft;
-
-    UI.setStyle(uploadWrapper, {
-      top: top + scrollTop + 'px',
-      left: left + scrollLeft + 'px'
-    });
-    UploadUI.showUploadSitesWrapper();
-    UploadUI.showOverlay();
-  },
-
-  hideUploadWrapper: function() {
-    UI.hide($('uploadWrapper'));
-    UploadUI.hideOverlay();
-  },
-
-  showOverlay: function() {
-    var overlay = $('overlay');
-    UI.setStyle(overlay, {
-      width: document.body.scrollWidth + 'px',
-      height: document.body.scrollHeight + 'px'
-    });
-    UI.show($('overlay'));
-  },
-
-  hideOverlay: function() {
-    UI.hide($('overlay'));
-  },
-
-  updateUploadHeader: function(title) {
-    $('uploadHeader').firstElementChild.firstElementChild.innerText = title;
-  },
-
-  showUploadSitesWrapper: function() {
-    var uploadHeader = chrome.i18n.getMessage('upload_sites_header');
-    UploadUI.updateUploadHeader(uploadHeader);
-    UI.show($('uploadSitesWrapper'));
-    UploadUI.hideUploadContentWrapper();
-    UI.hide($('lastStep'));
-  },
-
-  hideUploadSitesWrapper: function() {
-    UI.hide($('uploadSitesWrapper'));
-  },
-
-  showUploadContentWrapper: function(site) {
-    UploadUI.currentSite = site;
-
-    // Update upload wrapper UI
-    var uploadHeader = chrome.i18n.getMessage(site + '_upload_header');
-    UploadUI.updateUploadHeader(uploadHeader);
-    UploadUI.hideUploadSitesWrapper();
-    UploadUI.hideErrorInfo();
-    UploadUI.hideAuthenticationProgress();
-    UploadUI.clearPhotoDescription();
-    UI.show($('uploadContentWrapper'));
-    UI.show($('lastStep'));
-    UploadUI.updateShareToOtherAccountText(site);
-    UploadUI.togglePhotoDescriptionRequiredFlag(site);
-
-    // Show authenticated accounts of current site
-    UploadUI.clearAccounts();
-    var users = Account.getUsers(site);
-    for (var userId in users) {
-      UploadUI.addAuthenticatedAccount(site, userId);
-    }
-  },
-
-  hideUploadContentWrapper: function() {
-    UI.hide($('uploadContentWrapper'));
-  },
-
-  clearPhotoDescription: function() {
-    $('imageCaption').value = '';
-  },
-
-  validatePhotoDescription: function(site) {
-    var caption = $('imageCaption');
-    var invalidCaptionMsg = chrome.i18n.getMessage('invalid_caption');
-
-    // Validate photo description
-    if (site == SinaMicroblog.siteId && caption.value == '') {
-      UploadUI.showErrorInfo(invalidCaptionMsg);
-      caption.focus();
-      return false;
-    }
-    return true;
-  },
-
-  togglePhotoDescriptionRequiredFlag: function(siteId) {
-    if (siteId == SinaMicroblog.siteId)
-      UI.show($('requiredFlag'));
-    else
-      UI.hide($('requiredFlag'));
-  },
-
-  updateShareToOtherAccountText: function(siteId) {
-    var users = Account.getUsers(siteId);
-    var userLength = Object.keys(users).length;
-    if (userLength)
-      i18nReplace('shareToOtherAccount', 'share_to_other_account');
-    else
-      i18nReplace('shareToOtherAccount', 'share_to_' + siteId + '_account');
-  },
-
-  showErrorInfo: function(text) {
-    UI.show($('errorWrapper'));
-    $('errorInfo').innerHTML = text;
-    setTimeout(function() {
-      UploadUI.hideErrorInfo();
-    }, HIDE_ERROR_INFO_DELAY_TIME);
-  },
-
-  hideErrorInfo: function() {
-    UI.hide($('errorWrapper'));
-  },
-
-  showProgressBar: function(accountId) {
-    var progress = document.querySelector('#' + accountId +
-      ' .progressBar');
-    UI.show(progress);
-  },
-
-  hideProgressBar: function(accountId) {
-    var progress = document.querySelector('#' + accountId +
-      ' .progressBar');
-    UI.hide(progress);
-  },
-
-  showAuthenticationProgress: function(title) {
-    var progress = $('authenticationProgress');
-    progress.setAttribute('title', title);
-    UI.show(progress);
-  },
-
-  hideAuthenticationProgress: function() {
-    UI.hide($('authenticationProgress'));
-  },
-
-  setProgress: function(accountId, loaded, total) {
-    console.log('In setProgress, loaded: ' + loaded + ', total: ' + total);
-    var progress = document.querySelector('#' + accountId + ' .progressBar');
-
-    // One progress bar has 4 parts to represent progress
-    var level = parseInt(loaded / total / 0.25);
-    UI.setStyle(progress, 'background-position-y', '-' + (12 * level) + 'px');
-  },
-
-  showPhotoLink: function(accountId, link) {
-    var photoLink = document.querySelector('#' + accountId + ' .photoLink');
-    photoLink.setAttribute('href', link);
-    UI.setStyle(photoLink, 'display', 'inline');
-  },
-
-  hidePhotoLink: function(accountId) {
-    var photoLink = document.querySelector('#' + accountId + ' .photoLink');
-    UI.hide(photoLink);
-  },
-
-  showUploadInfo: function(accountId, text) {
-    var uploadInfo = document.querySelector('#' + accountId + ' .uploadInfo');
-    uploadInfo.innerHTML = text;
-    UI.show(uploadInfo);
-  },
-
-  hideUploadInfo: function(accountId) {
-    var uploadInfo = document.querySelector('#' + accountId + ' .uploadInfo');
-    UI.hide(uploadInfo);
-  },
-
-  clearAccounts: function() {
-    $('uploadAccountList').innerHTML = '';
-  },
-
-  addAuthenticatedAccount: function(site, userId) {
-    var template = $('accountItemTemplate').innerHTML;
-
-    // Replace i18n message
-    template = template.replace(/\$\{accountId\}/gi, site + '_' + userId);
-    var shareToText = chrome.i18n.getMessage('share_to');
-    template = template.replace(/\$\{accountName\}/gi,
-      shareToText + ' ' + Account.getUser(site, userId)['name']);
-    template = template.replace('${site}', site);
-    template = template.replace('${userId}', userId);
-    template = template.replace(/\$\{deletionTitle\}/gi,
-      chrome.i18n.getMessage('deletion_title'));
-    template = template.replace(/\$\{photoLinkText\}/gi,
-      chrome.i18n.getMessage('photo_link_text'));
-    template = template.replace(/\$\{progressInfo\}/gi,
-      chrome.i18n.getMessage('progress_info'));
-
-    // At most show 3 authenticated users
-    var uploadAccountList = $('uploadAccountList');
-    var accountsNumber = uploadAccountList.childElementCount;
-    if (accountsNumber == 2) {
-      uploadAccountList.removeChild(uploadAccountList.lastElementChild);
-    }
-    uploadAccountList.innerHTML = template + uploadAccountList.innerHTML;
-
-    $('accountName').addEventListener('click', function(e) {
-      UploadUI.upload(site, userId);
-    });
-    $('deleteBtn').addEventListener('click', function(e) {
-      e.stopPropagation();
-      UploadUI.deleteAccountItem(site + '_' + userId);
-    });
-
-    UploadUI.updateShareToOtherAccountText(site);
-  },
-
-  deleteAccountItem: function(accountId, noConfirm) {
-    if (UploadUI.uploading && !noConfirm)
-      return;
-    var confirmText = chrome.i18n.getMessage('account_deletion_confirm');
-    if (noConfirm || confirm(confirmText)) {
-      $('uploadAccountList').removeChild($(accountId));
-
-      // Clear localStorage
-      var site = accountId.split('_')[0];
-      var userId = accountId.split('_')[1];
-      Account.removeUser(site, userId);
-      UploadUI.updateShareToOtherAccountText(site);
-    }
-  },
-
-  upload: function(siteId, userId) {
-    if (UploadUI.uploading)
-      return;
-
-    // Initialize UI
-    var accountId = siteId + '_' + userId;
-    UploadUI.hideErrorInfo();
-    UploadUI.hideUploadInfo(accountId);
-    UploadUI.hidePhotoLink(accountId);
-    if (!UploadUI.validatePhotoDescription(siteId))
-      return;
-    var caption = $('imageCaption').value;
-
-    // Get ready for upload image.
-    photoshop.draw();
-    UploadUI.setUploading(true);
-    UploadUI.showProgressBar(accountId);
-
-    var site = UploadUI.getSiteObject(siteId);
-    var user = Account.getUser(siteId, userId);
-    var imageData = UploadUI.getImageData();
-    var infoText;
-
-    var callback = function(result, photoIdOrMessage) {
-      if (result == 'success') {
-        infoText = chrome.i18n.getMessage('get_photo_link');
-        UploadUI.showUploadInfo(accountId, infoText);
-        site.getPhotoLink(user, photoIdOrMessage, function(photoLinkResult,
-                                                           photoLinkOrMessage) {
-          if (photoLinkResult == 'success') {
-            UploadUI.setUploading(false);
-            UploadUI.hideUploadInfo(accountId);
-            UploadUI.showPhotoLink(accountId, photoLinkOrMessage);
-          } else {
-            UploadUI.showErrorInfo(photoLinkOrMessage);
-          }
-        });
-      } else {
-        if (photoIdOrMessage == 'bad_access_token' ||
-            photoIdOrMessage == 'invalid_album_id') {
-          Account.removeUser(site.siteId, site.currentUserId);
-          UploadUI.deleteAccountItem(accountId, true);
-          UploadUI.getAccessToken(siteId);
-        }
-        UploadUI.setUploading(false);
-        UploadUI.hideProgressBar(accountId);
-        UploadUI.showErrorInfo(chrome.i18n.getMessage(photoIdOrMessage));
-      }
-      UploadUI.hideProgressBar(accountId);
-    };
-
-    if (user) {
-      site.currentUserId = user.id;
-      site.upload(user, caption, imageData, callback);
-    } else {
-      UploadUI.getAccessToken(siteId);
-    }
-  },
-
-  getAccessToken: function(siteId) {
-    var site = UploadUI.getSiteObject(siteId);
-    var accessTokenCallback = function(result, userOrMessage) {
-      if (result == 'success') {
-        UploadUI.getUserInfo(siteId, userOrMessage);
-      } else {
-        // Show error information according to error reason
-        UploadUI.showErrorInfo(chrome.i18n.getMessage(userOrMessage));
-        UploadUI.hideAuthenticationProgress();
-      }
-    };
-
-    site.getAccessToken(accessTokenCallback);
-  },
-
-  getUserInfo: function(siteId, user) {
-    var site = UploadUI.getSiteObject(siteId);
-    site.getUserInfo(user, function(result, userOrMessage) {
-      if (result == 'success') {
-        var userId = user.id;
-        // Check if the authenticated user is added.
-        if (!Account.getUser(siteId, userId)) {
-          site.currentUserId = userId;
-          Account.addUser(siteId, user);
-          UploadUI.addAuthenticatedAccount(siteId, userId);
-        }
-        UploadUI.upload(siteId, userId);
-      } else {
-        var msg = chrome.i18n.getMessage(userOrMessage);
-        UploadUI.showErrorInfo(msg);
-      }
-      UploadUI.hideAuthenticationProgress();
-    });
-  },
-
-  getImageData: function() {
-    var dataUrl = $('canvas').toDataURL('image/png');
-    var imageDataIndex = dataUrl.indexOf('data:image/png;base64,');
-    if (imageDataIndex != 0) {
-      return;
-    }
-
-    // Decode to binary data
-    return atob(dataUrl.substr(imageDataIndex + 22));
-  },
-
-  saveImage: function() {
-    $('canvas').toBlob(function(blob) {
-      console.log(chrome.extension.getBackgroundPage());
-      saveAs(blob, chrome.extension.getBackgroundPage().screenshot.screenshotName+".png");
-    });
-  }
-};
-
-(function() {
-// Cache tab id of edit page, so that we can get tab focus after getting access
-// token.
-var tabIdOfEditPage;
-chrome.tabs.getSelected(null, function(tab) {
-  tabIdOfEditPage = tab.id;
-});
-
-function selectTab(tabId) {
-  chrome.tabs.update(tabId, {
-    selected: true
-  });
-}
-
-function closeTab(tabId) {
-  chrome.tabs.remove(tabId);
-}
-
-function parseAccessToken(senderId, url, siteId) {
-  var sites = UploadUI.sites;
-  for (var id in sites) {
-    var site = sites[id];
-    if ((siteId && id == siteId) || site.isRedirectUrl(url)) {
-      selectTab(tabIdOfEditPage);
-      closeTab(senderId);
-      site.parseAccessToken(url);
-      return true;
-    }
-  }
-  return false;
-}
-
-chrome.extension.onMessage.addListener(function(request, sender) {
-  switch (request.msg) {
-  case 'url_for_access_token':
-    parseAccessToken(sender.tab.id, request.url, request.siteId);
-    break;
-  }
-});
-})();
diff --git a/src/options.html b/src/options.html
index b0e51ec..30c652b 100644
--- a/src/options.html
+++ b/src/options.html
@@ -242,7 +242,6 @@
       </pre>
     </details>
   </div>
-  <script src="js/hotkey_storage.js"></script>
   <script src="js/ui.js"></script>
   <script src="js/options.js"></script>
 </body>
diff --git a/src/showimage.html b/src/showimage.html
index 745bd7c..309e39e 100644
--- a/src/showimage.html
+++ b/src/showimage.html
@@ -176,16 +176,7 @@
   <div id="overlay"></div>
   <script src="lib/FileSaver.min.js"></script>
   <script src="js/editor.js"></script>
-  <script src="js/sha1.js"></script>
-  <script src="js/oauth.js"></script>
-  <script src="js/ajax.js"></script>
-  <script src="js/account.js"></script>
   <script src="js/ui.js"></script>
-  <script src="js/upload_ui.js"></script>
-  <script src="js/facebook.js"></script>
-  <script src="js/sina_microblog.js"></script>
-  <script src="js/picasa.js"></script>
-  <script src="js/imgur.js"></script>
   <script src="js/showimage.js"></script>
 </body>
 </html>
