Skip to content

Commit b45b4ab

Browse files
committed
Added Archive.is to caches
Wayback Machine takes you to the latest page
1 parent d06a8ee commit b45b4ab

File tree

6 files changed

+69
-26
lines changed

6 files changed

+69
-26
lines changed

Chrome Store/ChromeStore.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is a chrome browser extension that allows the user to view a cached version of the current webpage. Set your primary cache as Google Cache, Wayback Machine, or Coral CDN. If what you're looking for isn't found, it'll cycle through the other caches until it finds what you're looking for. There are three ways to use WebCache:
1+
This is a chrome browser extension that allows the user to view a cached version of the current webpage. Set your primary cache as Google Cache, Wayback Machine, Archive.is, or Coral CDN. If what you're looking for isn't found, it'll cycle through the other caches until it finds what you're looking for. There are three ways to use WebCache:
22

33
1. Click the extension button to view the cached version of the web page
44

@@ -17,6 +17,8 @@ V 4.1.0
1717
--------
1818

1919
- Wayback Machine URL now takes you directly to the latest snapshot of a page
20+
- Added Archive.is as to the caches
21+
- Code Refactoring
2022

2123
V 4.0.0
2224
--------

context-menu.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
var CONTEXT_HASH = {
22
"google-cache": "http://webcache.googleusercontent.com/search?q=cache:",
33
"wayback-machine": "http://web.archive.org/web/",
4+
"archive-is": "http://archive.is/newest/",
45
"coral-cdn": ".nyud.net"
56
};
67

78
function formUrl(context, url) {
89
var contextUrl = CONTEXT_HASH[context];
910
var isHTTPS = url.substring(0, 6) === "https:";
1011

11-
// Google and Wayback Machine
12+
// Google, Wayback Machine, and Archive is
1213
if(context !== "coral-cdn") {
1314
return contextUrl + (isHTTPS ? url.substr(8) : url.substr(7));
1415
} else { // Coral CDN

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
"name": "WebCache",
55
"short_name" : "WebCache",
6-
"version": "4.0.1",
7-
"description": "Want to view a cached website (Google Cache, Wayback Machine, Coral CDN)? With WebCahce it only takes 1 click!",
6+
"version": "4.1.0",
7+
"description": "Want to view a cached website? With WebCache it takes 1 click to view the Google Cache, Wayback Machine, Archive.is, or Coral CDN!",
88
"browser_action": {
99
"default_title": "WebCache"
1010
},

options.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ <h3 class="title">WebCache Options</h3>
2727
<label class="context-menu-label" for="wayback-machine">Wayback Machine</label>
2828
</div>
2929

30+
<div class="context-cache">
31+
<input id="archive-is" class="checkbox" type="checkbox"/>
32+
<label class="context-menu-label" for="archive-is">Archive Is</label>
33+
</div>
34+
3035
<div class="context-cache">
3136
<input id="coral-cdn" class="checkbox" type="checkbox"/>
3237
<label class="context-menu-label" for="coral-cdn">Coral CDN</label>
@@ -43,10 +48,17 @@ <h3 class="title">WebCache Options</h3>
4348
<p>Google Cache</p>
4449
<span class="ui-icon ui-icon-grip-dotted-horizontal icon"></span>
4550
</li>
51+
4652
<li class="list-item" id="wayback-machine-sortable">
4753
<p>Wayback Machine</p>
4854
<span class="ui-icon ui-icon-grip-dotted-horizontal icon"></span>
4955
</li>
56+
57+
<li class="list-item" id="archive-is-sortable">
58+
<p>Archive Is</p>
59+
<span class="ui-icon ui-icon-grip-dotted-horizontal icon"></span>
60+
</li>
61+
5062
<li class="list-item" id="coral-cdn-sortable">
5163
<p>Coral CDN</p>
5264
<span class="ui-icon ui-icon-grip-dotted-horizontal icon"></span>
@@ -77,4 +89,4 @@ <h3 class="title">WebCache Options</h3>
7789
<script src="options.js"></script>
7890
</body>
7991

80-
</html>
92+
</html>

options.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
var CONTEXT_MENU_CACHES = [
22
"google-cache",
33
"wayback-machine",
4+
"archive-is",
45
"coral-cdn"
56
];
67

8+
var SORTABLE_CACHES = [
9+
"google-cache-sortable",
10+
"wayback-machine-sortable",
11+
"archive-is-sortable",
12+
"coral-cdn-sortable"
13+
];
14+
15+
716
// Remove context menu caches
817
function removeContextMenu(cache) {
918
var saveObj = {};
@@ -30,8 +39,8 @@ function createContextMenu(cache) {
3039
// Add/Remove context menu caches
3140
function updateContextMenuCaches(event) {
3241
var cache = $(event.target).attr("for");
33-
var add_context_menu = !$("#" + cache).is(":checked");
34-
add_context_menu ? createContextMenu(cache) : removeContextMenu(cache);
42+
var addContextMenu = !$("#" + cache).is(":checked");
43+
addContextMenu ? createContextMenu(cache) : removeContextMenu(cache);
3544
}
3645

3746
var order = [];
@@ -53,11 +62,22 @@ $("#sortable").sortable({
5362
chrome.storage.sync.get("cacheOrder4", function(result) {
5463
var ul = $("#sortable");
5564
var li = ul.children("li").get();
56-
order = result["cacheOrder4"] || ["google-cache-sortable", "wayback-machine-sortable", "coral-cdn-sortable"];
65+
order = result["cacheOrder4"] || SORTABLE_CACHES
5766

67+
if(order.length < SORTABLE_CACHES.length) { // We have just updated, so add the new caches and then save them
68+
order = order.concat($(SORTABLE_CACHES).not(order).get());
69+
var saveObj = {};
70+
saveObj["cacheOrder4"] = order;
71+
chrome.storage.sync.set(saveObj, function() {
72+
console.log("Saved Cache Ordering Preferences");
73+
});
74+
}
75+
76+
// Order the caches
5877
li.sort(function(a, b) {
5978
return order.indexOf($(a).attr("id")) - order.indexOf($(b).attr("id"));
6079
});
80+
6181
ul.append(li);
6282
});
6383

@@ -87,3 +107,4 @@ $("#myonoffswitch").click(function(event) {
87107
$(".context-menu-label").click(updateContextMenuCaches);
88108

89109
$("#sortable").disableSelection();
110+

redirect.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@ var isHTTPS = true;
33
var index = 0;
44
var numberOfRedirects = 0;
55
var redirecting = false;
6-
7-
var cacheURL = [
8-
"http://webcache.googleusercontent.com/search?q=cache:",
9-
"http://web.archive.org/web/",
10-
".nyud.net"
11-
];
12-
var cacheNames = [
6+
var sortableCaches = [
137
"google-cache-sortable",
148
"wayback-machine-sortable",
9+
"archive-is-sortable",
1510
"coral-cdn-sortable"
1611
];
12+
var cacheURLs = [
13+
"http://webcache.googleusercontent.com/search?q=cache:",
14+
"http://web.archive.org/web/",
15+
"http://archive.is/newest/",
16+
".nyud.net"
17+
];
18+
1719
var URL_HASH = [
1820
{ name: "google-cache-sortable", URL: "http://webcache.googleusercontent.com/search?q=cache:" },
1921
{ name: "wayback-machine-sortable", URL: "http://web.archive.org/web/*/" },
22+
{ name: "archive-is-sortable", URL: "http://archive.is/newest/" },
2023
{ name: "coral-cdn-sortable", URL: ".nyud.net" }
2124
];
2225

2326
function getURL() {
2427
++numberOfRedirects;
25-
if(cacheURL[index] == cacheURL.length) {
28+
if(cacheURLs[index] == cacheURLs.length) {
2629
index = 0;
2730
}
2831

29-
if(cacheURL[index] != ".nyud.net") { // Google and Wayback Machine
30-
return cacheURL[index] + (isHTTPS ? currentURL.substr(8) : currentURL.substr(7));
32+
if(cacheURLs[index] != ".nyud.net") { // Google, Wayback Machine, and Archive Is
33+
return cacheURLs[index] + (isHTTPS ? currentURL.substr(8) : currentURL.substr(7));
3134
} else { // Coral CDN
3235
if(currentURL.slice(-1) == "/") {
3336
return currentURL.substring(0, currentURL.length -1) + ".nyud.net";
@@ -39,7 +42,7 @@ function getURL() {
3942

4043
function handler(details) {
4144
//console.log("StatusLine is: " + details.statusLine);
42-
if(numberOfRedirects > cacheURL.length) { // There is no cache available
45+
if(numberOfRedirects > cacheURLs.length) { // There is no cache available
4346
chrome.webRequest.onHeadersReceived.removeListener(handler);
4447
redirecting = false;
4548
return { cancel: true };
@@ -60,19 +63,17 @@ function handler(details) {
6063

6164
function openPage(currentTab) {
6265
chrome.storage.sync.get("cacheOrder4", function(result) {
63-
var cacheOrder = result["cacheOrder4"] || cacheNames;
66+
var cacheOrder = result["cacheOrder4"] || sortableCaches;
6467

6568
URL_HASH.sort(function(a, b) {
6669
return cacheOrder.indexOf(a.name) - cacheOrder.indexOf(b.name);
6770
});
6871

69-
for(var i = 0; i < 3; i++) {
70-
cacheURL[i] = URL_HASH[i].URL;
71-
cacheNames[i] = URL_HASH[i].name;
72+
for(var i = 0; i < cacheURLs.length; i++) {
73+
cacheURLs[i] = URL_HASH[i].URL;
74+
sortableCaches[i] = URL_HASH[i].name;
7275
}
7376

74-
// console.log(cacheURL);
75-
7677
index = 0;
7778
numberOfRedirects = 0;
7879
redirecting = true;
@@ -139,12 +140,18 @@ chrome.runtime.onInstalled.addListener(function(details) {
139140
chrome.storage.sync.get("cacheOrder", function(result) {
140141
if(Object.keys(result).length == 0) {
141142
var saveObject = {
142-
"cacheOrder4": cacheNames,
143+
"cacheOrder4": sortableCaches,
143144
"auto-detect": "off"
144145
};
145146
chrome.storage.sync.set(saveObject);
147+
} else if(result["cacheOrder"].length < cacheURLs.length) {
148+
var saveObject = {
149+
"cacheOrder": result["cacheOrder"].concat($(sortableCaches)).not(result["cacheOrder"]).get())
150+
};
151+
chrome.storage.sync.set(saveObject);
146152
}
147153
});
148154
});
149155

150156
chrome.browserAction.onClicked.addListener(openPage);
157+

0 commit comments

Comments
 (0)