aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2018-04-17 13:06:28 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2018-04-17 13:06:28 +0200
commitcf162288dea28f027cc83f7a3820bcf629cbba27 (patch)
treed376bce584d6c1a2d6158d692ad3c6f0968bc420
parentab49453a0bbc602166c746a580f82612c4e161c8 (diff)
"Archive Now" button to make preferred archives with one click
-rw-r--r--README.md49
-rw-r--r--src/archiveror.js11
-rw-r--r--src/options.html4
-rw-r--r--src/popup.css2
-rw-r--r--src/popup.html8
-rw-r--r--src/popup.js35
6 files changed, 73 insertions, 36 deletions
diff --git a/README.md b/README.md
index a0b76f3..c5f3e8b 100644
--- a/README.md
+++ b/README.md
@@ -4,15 +4,14 @@
[![License](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://github.com/rahiel/archiveror/blob/master/LICENSE.txt)
Archiveror is a browser extension that archives webpages by submitting them to
-<https://archive.is>, <https://archive.org> and other archiving services. These
-archives are publicly available, so you then have a backup that you can refer to
-in case the original falls prey to [link rot][].
+[archive.is][], [archive.org][] and other archiving services. These archives are
+publicly available, so you then have a backup that you can refer to in case the
+original falls prey to [link rot][].
-Archiveror will also preserve your bookmarks by automatically archiving them in
-the background. Its icon will change when you visit a bookmark it has archived,
-clicking on it opens the page on the archive. Archiving of bookmarks happens
-when you make a new bookmark and when you open an old bookmark. This can be
-disabled.
+Archiveror also preserves your bookmarks by automatically archiving them in the
+background. Its icon changes when you visit a bookmark it has archived, clicking
+on it shows the archive links. Archiving of bookmarks happens when you make a
+new bookmark and when you open an old bookmark. This can be disabled.
You can manually archive webpages by clicking on the icon, using the Alt+Shift+Y
hotkey (configurable), or via the page's right click context menu. The URL for
@@ -21,13 +20,16 @@ for references and citations.
Happy archiving!
+[archive.is]: https://archive.is
+[archive.org]: https://archive.org
[link rot]: https://en.wikipedia.org/wiki/Link_rot
## Archiving Services
-Archiveror supports several online archiving service. You can choose which one
-to use for manual archiving at the options. You can also select multiple
-services to archive a single page in multiple web archives.
+Archiveror supports several online archiving service. When clicking on the icon,
+you'll see an "Archive Now" button. You can select which archiving services to
+use when you click this button at the options, there you can also select
+multiple services to archive a single page at multiple web archives.
- [**archive.is**](https://archive.is), launched in 2012. Blocks (some)
advertising and (user tracking) JavaScript. Links:
@@ -58,19 +60,18 @@ services to archive a single page in multiple web archives.
## Local Saving
-Archiveror can also make local copies of webpages. One page will be saved in a
-single [MHTML][] file. Bookmarks will be saved automatically. Pages can also be
-manually saved by either clicking the button or pressing Ctrl+Shift+S. The
-filenames end with the UTC date and time of when the archive was made.
-
-To enable local archiving, right click the Archiveror button, go to the options
-and then pick "Local".
-
-In local archiving mode your bookmarks will be saved in your Downloads directory
-following your bookmark structure. If you move your bookmarks around, Archiveror
-will mirror your changes and likewise move your local archives. For this to work
-you need to check "Allow access to file URLs" at the extensions page. Go to your
-extensions and enable it: <https://i.imgur.com/ahrfe3M.png>.
+Archiveror also makes local copies of webpages. It saves one web page in a
+single [MHTML][] file. Save pages manually by either clicking the button or by
+pressing Ctrl+Shift+S. The filenames end with the UTC date and time of when the
+archive was made.
+
+To enable local archiving of bookmarks, right click the Archiveror button, go to
+the options and then select "MHTML" at the "Bookmarks" section. With this option
+enabled your bookmarks will be saved in your Downloads directory following your
+bookmark structure. If you move your bookmarks around, Archiveror will mirror
+your changes and likewise move your local archives. For this to work you need to
+check "Allow access to file URLs" at the extensions page. Go to your extensions
+and enable it: <https://i.imgur.com/ahrfe3M.png>.
Local saving is currently only available for Chromium, vote
for [this bug][1261339] if you want this feature on Firefox. Alternatively
diff --git a/src/archiveror.js b/src/archiveror.js
index 291ed35..c565b47 100644
--- a/src/archiveror.js
+++ b/src/archiveror.js
@@ -32,6 +32,7 @@ function archiveOnline(url, services) {
if (services === undefined) {
services = items.archiveServices;
}
+ services = services.filter(s => s !== "mhtml");
for (let service of services) {
link = getArchivingURL(url, service, items.email);
@@ -67,6 +68,16 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
chrome.tabs.get(message.tabId, function (tab) {
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);
+ });
+ }
+ });
}
});
diff --git a/src/options.html b/src/options.html
index 2f053e2..c9b9b60 100644
--- a/src/options.html
+++ b/src/options.html
@@ -9,8 +9,8 @@
</style>
</head>
<body>
- <h3>Archiving Service</h3>
- <p>The archiving service(s) to use for manual archiving.</p>
+ <h3>Archive Now</h3>
+ <p>The archives to make when you click the Archive Now button.</p>
<label for="archive.is">
<input type="checkbox" name="service" id="archive.is" value="archive.is">
<a href="https://archive.is/">archive.is</a>
diff --git a/src/popup.css b/src/popup.css
index f6f01c3..9a62f54 100644
--- a/src/popup.css
+++ b/src/popup.css
@@ -25,6 +25,6 @@ a {
a:hover { text-decoration: underline; }
a:visited { color: #609; }
-#bookmarkSection {
+#bookmarkSection, #local {
display: none;
}
diff --git a/src/popup.html b/src/popup.html
index 6da76b8..f486a24 100644
--- a/src/popup.html
+++ b/src/popup.html
@@ -6,14 +6,18 @@
<title>Archiveror</title>
</head>
<body>
+ <button type="button" id="now">Archive Now!</button>
+
<h3>Archive Online</h3>
<button type="button" id="archive.is">archive.is</button>
<button type="button" id="archive.org">archive.org</button>
<button type="button" id="perma.cc">perma.cc</button>
<button type="button" id="webcitation.org">webcitation.org</button>
- <h3>Archive Locally</h3>
- <button type="button" id="mhtml">MHTML</button>
+ <div id="local">
+ <h3>Archive Locally</h3>
+ <button type="button" id="mhtml">MHTML</button>
+ </div>
<div id="bookmarkSection">
<h3>Bookmark</h3>
diff --git a/src/popup.js b/src/popup.js
index b80e237..a418b57 100644
--- a/src/popup.js
+++ b/src/popup.js
@@ -1,4 +1,7 @@
-function click(services) {
+import { hasPageCapture } from "./utils.js";
+
+
+function requestOnline(services) {
function requestArchive() {
chrome.tabs.query({active: true, lastFocusedWindow: true}, function (tabs) {
@@ -24,14 +27,28 @@ function requestMHTML() {
});
}
-document.getElementById("archive.is").onclick = click(["archive.is"]);
-document.getElementById("archive.org").onclick = click(["archive.org"]);
-document.getElementById("perma.cc").onclick = click(["perma.cc"]);
-document.getElementById("webcitation.org").onclick = click(["webcitation.org"]);
+function requestArchiveNow() {
+ chrome.tabs.query({active: true, lastFocusedWindow: true}, function (tabs) {
+ let tab = tabs[0];
+ chrome.runtime.sendMessage({
+ label: "archiveNow",
+ tabId: tab.id,
+ url: tab.url,
+ });
+ });
+}
+
+document.getElementById("now").onclick = requestArchiveNow;
+
+document.getElementById("archive.is").onclick = requestOnline(["archive.is"]);
+document.getElementById("archive.org").onclick = requestOnline(["archive.org"]);
+document.getElementById("perma.cc").onclick = requestOnline(["perma.cc"]);
+document.getElementById("webcitation.org").onclick = requestOnline(["webcitation.org"]);
document.getElementById("mhtml").onclick = requestMHTML;
-function showBookmarkArchives() {
+function showElements() {
+ // show elements when they're useful
chrome.tabs.query({active: true, lastFocusedWindow: true}, function (tabs) {
let url = tabs[0].url;
chrome.storage.local.get([url, "_" + url], function (items) {
@@ -54,7 +71,11 @@ function showBookmarkArchives() {
document.getElementById("archiveList").appendChild(e);
showBookmarkSection = true;
}
+
+ if (hasPageCapture) {
+ document.getElementById("local").style.display = "block";
+ }
});
});
}
-showBookmarkArchives();
+showElements();