Fix extension

- Delete social network code
- Fix save functionality
- Fix "Port closed" error
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>