aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2018-04-17 16:10:49 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2018-04-17 16:10:49 +0200
commitbbe3cfc86683d156650857ad34925b779a070533 (patch)
tree3c8d74198675e255aa98496ae2a52ffb7eec5c6f
parent6b75f9c7c795c931cd5bef2944c0a484f505ed27 (diff)
put "Archive Now" on the archive keyboard shortcut
-rw-r--r--src/archiveror.js30
-rw-r--r--src/manifest.json6
-rw-r--r--src/options.html5
3 files changed, 24 insertions, 17 deletions
diff --git a/src/archiveror.js b/src/archiveror.js
index c565b47..c3f6fb0 100644
--- a/src/archiveror.js
+++ b/src/archiveror.js
@@ -69,18 +69,22 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
saveLocal(tab, false);
});
} else if (message.label === "archiveNow") {
- chrome.storage.local.get({archiveServices: defaults.archiveServices}, function (items) {
- let services = items.archiveServices;
- archiveOnline(message.url, services);
- if (services.includes("mhtml")) {
- chrome.tabs.get(message.tabId, function (tab) {
- saveLocal(tab, false);
- });
- }
- });
+ archiveNow(message.url, message.tabId);
}
});
+function archiveNow(url, tabId) {
+ chrome.storage.local.get({archiveServices: defaults.archiveServices}, function (items) {
+ const services = items.archiveServices;
+ archiveOnline(url, services);
+ if (services.includes("mhtml")) {
+ chrome.tabs.get(tabId, function (tab) {
+ saveLocal(tab, false);
+ });
+ }
+ });
+}
+
function showArchive(url, bookmark) {
// Notify user if we have an archive of the current page, otherwise archive if needed
let keys = {
@@ -197,13 +201,13 @@ function saveLocal(tab, automatic, path) {
// Keyboard shortcuts
chrome.commands.onCommand.addListener(function (command) {
- let action;
- if (command === "archive-page") {
- action = function (tabs) { archiveOnline(tabs[0].url); };
+ let action = false;
+ if (command === "archive-now") {
+ action = function (tabs) { archiveNow(tabs[0].url, tabs[0].id); };
} else if (command === "save-local") {
action = function (tabs) { saveLocal(tabs[0], false); };
}
- if (typeof action !== "undefined") {
+ if (action !== false) {
chrome.tabs.query({active: true, lastFocusedWindow: true}, action);
}
});
diff --git a/src/manifest.json b/src/manifest.json
index b6238b9..a76558a 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -51,13 +51,13 @@
},
"commands": {
- "archive-page": {
+ "archive-now": {
"suggested_key": {"default": "Alt+Shift+Y"},
- "description": "Archive current page online"
+ "description": "Archive Now"
},
"save-local": {
"suggested_key": {"default": "Ctrl+Shift+S"},
- "description": "Save current page locally as MHTML"
+ "description": "Save current page as MHTML"
}
},
diff --git a/src/options.html b/src/options.html
index c9b9b60..de4b706 100644
--- a/src/options.html
+++ b/src/options.html
@@ -10,7 +10,10 @@
</head>
<body>
<h3>Archive Now</h3>
- <p>The archives to make when you click the Archive Now button.</p>
+ <p>
+ The archives to make when you click the Archive Now button or when you
+ press the archive keyboard shortcut.
+ </p>
<label for="archive.is">
<input type="checkbox" name="service" id="archive.is" value="archive.is">
<a href="https://archive.is/">archive.is</a>