Remove shortcuts and adapt extension to activeTab permission
diff --git a/src/js/background.js b/src/js/background.js
index 021bed3..ff4eaef 100644
--- a/src/js/background.js
+++ b/src/js/background.js
@@ -270,23 +270,8 @@
     return navigator.userAgent.toLowerCase().indexOf(operationSystem) > -1;
   },
 
-  executeScriptsInExistingTabs: function() {
-    chrome.windows.getAll(null, function(wins) {
-      for (var j = 0; j < wins.length; ++j) {
-        chrome.tabs.getAllInWindow(wins[j].id, function(tabs) {
-          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' });
-            }
-          }
-        });
-      }
-    });
-  },
-
   init: function() {
     localStorage.screenshootQuality = localStorage.screenshootQuality || 'png';
-    screenshot.executeScriptsInExistingTabs();
     screenshot.addMessageListener();
   }
 };
diff --git a/src/js/options.js b/src/js/options.js
index bbbce70..abb2efc 100644
--- a/src/js/options.js
+++ b/src/js/options.js
@@ -28,9 +28,11 @@
 }

 

 function save() {

-  localStorage.screenshootQuality =

+  chrome.storage.local.set({

+    'screenshootQuality': 

       $('lossy').checked ? 'jpeg' : '' ||

-      $('lossless').checked ? 'png' : '';

+      $('lossless').checked ? 'png' : '',

+  });

 

   return true;

 }

@@ -43,8 +45,10 @@
 }

 

 function initScreenCaptureQuality() {

-  $('lossy').checked = localStorage.screenshootQuality == 'jpeg';

-  $('lossless').checked = localStorage.screenshootQuality == 'png';

+  chrome.storage.local.get('screenshotQuality', value => {

+    $('lossy').checked = value == 'jpeg';

+    $('lossless').checked = value == 'png';

+  });

 }

 

 function i18nReplace(id, name) {

diff --git a/src/js/page.js b/src/js/page.js
index 9ca2463..5fe494d 100644
--- a/src/js/page.js
+++ b/src/js/page.js
@@ -847,10 +847,11 @@
   /**

   * Remove an element

   */

-  init: function() { 

+  init: function() {

     if (document.body.hasAttribute('screen_capture_injected')) {

       return;

     }

+    document.body.setAttribute('screen_capture_injected', true);

     if (isPageCapturable()) {

       chrome.extension.sendMessage({msg: 'page_capturable'});

     } else {

diff --git a/src/js/popup.js b/src/js/popup.js
index 2319055..5eeb471 100644
--- a/src/js/popup.js
+++ b/src/js/popup.js
@@ -72,80 +72,98 @@
   document.body.style.minWidth = "140px";
 
   var isScriptLoad = false;
-  chrome.tabs.getSelected(null, function(tab) {
+  chrome.tabs.query({
+    active: true,
+  }, function(tabs) {
+    if (tabs.length < 1) {
+      console.error('Expected 1 tab');
+      return;
+    }
+    var tab = tabs[0];
     if (tab.url.indexOf('chrome') == 0 || tab.url.indexOf('about') == 0) {
       i18nReplace('tip', 'special');
       return;
-    } else {
-      $('tip').style.display = 'none';
-      $('captureSpecialPageItem').style.display = 'block';
-      showOption();
     }
-    chrome.tabs.sendMessage(tab.id, {msg: 'is_page_capturable'},
-      function(response) {
-        isScriptLoad = true;
-        if (response.msg == 'capturable') {
-          $('tip').style.display = 'none';
-          $('captureSpecialPageItem').style.display = 'none';
-          $('captureWindowItem').style.display = 'block';
-          $('captureAreaItem').style.display = 'block';
-          $('captureWebpageItem').style.display = 'block';
-          var textWidth = $('captureWindowText')['scrollWidth'];
-          resizeDivWidth('captureWindowText', textWidth);
-          resizeDivWidth('captureAreaText', textWidth);
-          resizeDivWidth('captureWebpageText', textWidth);
-          var bg = chrome.extension.getBackgroundPage();
-          if (bg.screenshot.isThisPlatform('mac')) {
-            $('captureAreaShortcut').innerText = '\u2325\u2318R';
-            $('captureWindowShortcut').innerText = '\u2325\u2318V';
-            $('captureWebpageShortcut').innerText = '\u2325\u2318H';
-          }
-        } else if (response.msg == 'uncapturable') {
-          i18nReplace('tip', 'special');
-          $('tip').style.display = 'block';
-        } else {
-          i18nReplace('tip', 'loading');
-        }
-      });
-  });
-  chrome.tabs.executeScript(null, {file: 'js/isLoad.js'});
-  var insertScript = function() {
-    if (isScriptLoad == false) {
-      chrome.tabs.getSelected(null, function(tab) {
-        if (tab.url.indexOf('chrome') == 0 ||
-            tab.url.indexOf('about') == 0) {
-          i18nReplace('tip', 'special');
-        } else {
-          $('tip').style.display = 'none';
-          $('captureSpecialPageItem').style.display = 'block';
-          showOption();
-        }
-      });
-    }
-    var captureItems = document.querySelectorAll('li.menuI');
-    var showSeparator = false;
-    for (var i = 0; i < captureItems.length; i++) {
-      if (window.getComputedStyle(captureItems[i]).display != 'none') {
-        showSeparator = true;
-        break;
-      }
-    }
-    $('separatorItem').style.display = showSeparator ? 'block' : 'none';
-  }
-  setTimeout(insertScript, 500);
+    chrome.tabs.executeScript({ file: 'js/page.js' }, _ => {
+      chrome.tabs.executeScript(null, {file: 'js/isLoad.js'}, _ => {
+        $('tip').style.display = 'none';
+        $('captureSpecialPageItem').style.display = 'block';
+        showOption();
 
-  // Update hot key.
-  $('captureSpecialPageItem').addEventListener('click', function(e) {
-    toDo('capture_special_page');
-  });
-  $('captureAreaItem').addEventListener('click', function(e) {
-    toDo('capture_area');
-  });
-  $('captureWindowItem').addEventListener('click', function(e) {
-    toDo('capture_window');
-  });
-  $('captureWebpageItem').addEventListener('click', function(e) {
-    toDo('capture_webpage');
+        chrome.tabs.sendMessage(tab.id, {msg: 'is_page_capturable'},
+          response => {
+            isScriptLoad = true;
+            if (response.msg == 'capturable') {
+              $('tip').style.display = 'none';
+              $('captureSpecialPageItem').style.display = 'none';
+              $('captureWindowItem').style.display = 'block';
+              $('captureAreaItem').style.display = 'block';
+              $('captureWebpageItem').style.display = 'block';
+              var textWidth = $('captureWindowText')['scrollWidth'];
+              resizeDivWidth('captureWindowText', textWidth);
+              resizeDivWidth('captureAreaText', textWidth);
+              resizeDivWidth('captureWebpageText', textWidth);
+              var bg = chrome.extension.getBackgroundPage();
+              if (bg.screenshot.isThisPlatform('mac')) {
+                $('captureAreaShortcut').innerText = '\u2325\u2318R';
+                $('captureWindowShortcut').innerText = '\u2325\u2318V';
+                $('captureWebpageShortcut').innerText = '\u2325\u2318H';
+              }
+            } else if (response.msg == 'uncapturable') {
+              i18nReplace('tip', 'special');
+              $('tip').style.display = 'block';
+            } else {
+              i18nReplace('tip', 'loading');
+            }
+          });
+
+          var insertScript = function() {
+            if (isScriptLoad == false) {
+              chrome.tabs.query({
+                active: true,
+              }, function(tabs) {
+                if (tabs.length < 1) {
+                  console.error('Expected 1 tab.');
+                  return;
+                }
+                var tab = tabs[0];
+                if (tab.url.indexOf('chrome') == 0 ||
+                    tab.url.indexOf('about') == 0) {
+                  i18nReplace('tip', 'special');
+                } else {
+                  $('tip').style.display = 'none';
+                  $('captureSpecialPageItem').style.display = 'block';
+                  showOption();
+                }
+              });
+            }
+            var captureItems = document.querySelectorAll('li.menuI');
+            var showSeparator = false;
+            for (var i = 0; i < captureItems.length; i++) {
+              if (window.getComputedStyle(captureItems[i]).display != 'none') {
+                showSeparator = true;
+                break;
+              }
+            }
+            $('separatorItem').style.display = showSeparator ? 'block' : 'none';
+          }
+          setTimeout(insertScript, 500);
+
+          // Update hot key.
+          $('captureSpecialPageItem').addEventListener('click', function(e) {
+            toDo('capture_special_page');
+          });
+          $('captureAreaItem').addEventListener('click', function(e) {
+            toDo('capture_area');
+          });
+          $('captureWindowItem').addEventListener('click', function(e) {
+            toDo('capture_window');
+          });
+          $('captureWebpageItem').addEventListener('click', function(e) {
+            toDo('capture_webpage');
+          });
+      });
+    });
   });
 }
 
diff --git a/src/js/showimage.js b/src/js/showimage.js
index b0d5f03..6e6d8ad 100644
--- a/src/js/showimage.js
+++ b/src/js/showimage.js
@@ -504,13 +504,15 @@
 
   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();
+    chrome.storage.local.get('screenshotQuality', formatParam => {
+      var formatParam = formatParam || '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) {
diff --git a/src/manifest.json b/src/manifest.json
index c6ca1a0..441e5b9 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -12,17 +12,6 @@
     "default_title": "__MSG_default_title__",
     "default_popup": "popup.html"
   },
-  "content_scripts": [ {
-    "matches": ["http://*/*", "https://*/*", "ftp://*/*", "file://*/*"],
-    "js": ["js/page.js", "js/shortcut.js"],
-    "css": ["style.css"],
-    "run_at": "document_end"
-  }, {
-    "matches": ["http://*/*", "https://*/*", "ftp://*/*", "file://*/*"],
-    "js": ["js/isLoad.js"],
-    "run_at": "document_start"
-    }
-  ],
   "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
   "default_locale": "en",
   "icons": {
@@ -34,7 +23,10 @@
   },
   "manifest_version": 2,
   "options_page": "options.html",
-  "permissions": ["tabs", "<all_urls>"],
+  "permissions": [
+    "storage",
+    "activeTab"
+  ],
   "web_accessible_resources": [
     "js/page_context.js",
     "style.css"
diff --git a/src/options.html b/src/options.html
index 30c652b..1159e8c 100644
--- a/src/options.html
+++ b/src/options.html
@@ -120,24 +120,6 @@
     color:#aca799;

     line-height: 18px;

   }

-  #hot-key-setting {

-    margin: 26px 0 0 80px;

-  }

-  .hot-key {

-    display: inline-block;

-    width: 200px;

-    margin: 0 30px 5px 0;

-  }

-  #hot-key-setting .capture-text {

-    margin-right: 10px;

-  }

-  #error-info {

-    margin: 5px 0 5px 80px;

-    color: red;

-  }

-  #screen-capture-hot-key-set-wrapper {

-    display: none;

-  }

   </style>

  </head>

 <body>

@@ -153,28 +135,6 @@
        </span></label> </div>

      <div class="clear"></div>

     </div>

-    <div id="shortcutSettingDiv" style="margin: 0px 0px 5px 0px">

-      <h4 id="shorcutSetting"></h4>

-      <div style="margin: 2px 0px 0px 56px">

-         <input type="checkbox" id="settingShortcut">

-         <label for="settingShortcut" id="settingShortcutText"></label>

-      </div>

-      <div id="hot-key-setting">

-        <span class="hot-key">

-          <label for="area-capture-hot-key" class="capture-text" id="area-capture-text"></label>

-          <span>Ctrl+Alt+<select id="area-capture-hot-key"></select></span>

-        </span>

-        <span class="hot-key">

-          <label for="viewport-capture-hot-key" class="capture-text" id="viewport-capture-text"></label>

-          <span>Ctrl+Alt+<select id="viewport-capture-hot-key"></select></span>

-        </span>

-        <span class="hot-key">

-          <label for="full-page-capture-hot-key" class="capture-text" id="full-page-capture-text"></label>

-          <span>Ctrl+Alt+<select id="full-page-capture-hot-key"></select></span>

-        </span>

-      </div>

-      <div id="error-info"></div>

-    </div>

     <div class="closeBtn"><button id="saveAndClose"></button>

     </div>

     <div style="margin-top: 20px; border-bottom: 2px dotted grey;">