Updated with latest version from Arrantius
- Add "list all versions" for The Internet Archive. - Add MementoWeb TimeTravel source. -Updated translation
This commit is contained in:
parent
71975d7125
commit
e0155d5ab6
8 changed files with 121 additions and 62 deletions
|
@ -10,11 +10,12 @@ Or, the easier route, use this extension.
|
|||
|
||||
## Features
|
||||
|
||||
* Searches through seven page cache/mirrors:
|
||||
* Searches through six page cache/mirrors:
|
||||
* [Google Cache](http://www.google.com/) (plus text-only version)
|
||||
* [The Internet Archive](http://web.archive.org/)
|
||||
* [WebCite](http://www.webcitation.org/)
|
||||
* [archive.is](https://archive.is/)
|
||||
* [Memento Time Travel](http://timetravel.mementoweb.org/)
|
||||
* [Down for everyone?](http://www.isup.me/)
|
||||
|
||||
Of course, not every page can be in every cache.
|
||||
|
@ -27,6 +28,11 @@ Hit back and try another one!
|
|||
* With the keyboard: press `Ctrl-Shift-U`
|
||||
|
||||
# Changelog
|
||||
|
||||
* Version 6
|
||||
* Merged with latest version from Arrantius
|
||||
* Add "list all versions" for The Internet Archive.
|
||||
* Add MementoWeb TimeTravel source.
|
||||
* Version 5
|
||||
* Merged with WebExtensions version from Arrantius (#3 #10)
|
||||
* Does not include netError page ([not currently possible](http://bugzil.la/1376793))
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
"description": "with The Internet Archive"
|
||||
},
|
||||
|
||||
"resurrectArchiveList": {
|
||||
"message": "with The Internet Archive (list all)",
|
||||
"description": "with The Internet Archive (list all)"
|
||||
},
|
||||
|
||||
"resurrectArchiveIs": {
|
||||
"message": "with archive.is",
|
||||
"description": "with archive.is"
|
||||
|
@ -44,6 +49,11 @@
|
|||
"description": "with WebCite"
|
||||
},
|
||||
|
||||
"resurrectMementoWeb": {
|
||||
"message": "with Memento Timetravel",
|
||||
"description": "with Memento Timetravel"
|
||||
},
|
||||
|
||||
"resurrectIsUp": {
|
||||
"message": "check if really down",
|
||||
"description": "with isup.me"
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
"description": "with The Internet Archive"
|
||||
},
|
||||
|
||||
"resurrectArchiveList": {
|
||||
"message": "avec l'Archive Internet (historique)",
|
||||
"description": "with The Internet Archive (list all)"
|
||||
},
|
||||
|
||||
"resurrectArchiveIs": {
|
||||
"message": "avec archive.is",
|
||||
"description": "with archive.is"
|
||||
|
@ -44,6 +49,11 @@
|
|||
"description": "with WebCite"
|
||||
},
|
||||
|
||||
"resurrectMementoWeb": {
|
||||
"message": "avec Memento Timetravel",
|
||||
"description": "with Memento Timetravel"
|
||||
},
|
||||
|
||||
"resurrectIsUp": {
|
||||
"message": "Vérifier si le site est mort",
|
||||
"description": "with isup.me"
|
||||
|
|
|
@ -1,65 +1,73 @@
|
|||
function onCreated(n) {
|
||||
}
|
||||
|
||||
chrome.storage.local.get('openIn', item => {
|
||||
if (item.openIn) {
|
||||
openIn = item.openIn;
|
||||
}
|
||||
|
||||
function addResurrectItem(context, i18n, id, icon) {
|
||||
chrome.contextMenus.create({
|
||||
id: 'resurrect-' + id + '-' + context,
|
||||
title: chrome.i18n.getMessage('resurrect' + i18n),
|
||||
icons: {16: 'icons/cacheicons/' + icon + '.png'},
|
||||
contexts: [context],
|
||||
parentId: 'resurrect-' + context
|
||||
}, onCreated);
|
||||
}
|
||||
|
||||
function addConfigItem(context, i18n, where, checked) {
|
||||
chrome.contextMenus.create({
|
||||
id: 'resurrect-' + where + '-' + context,
|
||||
type: 'radio',
|
||||
title: chrome.i18n.getMessage('resurrectConfig' + i18n),
|
||||
contexts: [context],
|
||||
checked: checked,
|
||||
parentId: 'resurrect-' + context
|
||||
}, onCreated);
|
||||
}
|
||||
|
||||
['page', 'link'].forEach(context => {
|
||||
chrome.contextMenus.create({
|
||||
contexts: [context],
|
||||
id: 'resurrect-' + context,
|
||||
title: chrome.i18n.getMessage('resurrect_' + context),
|
||||
contexts: [context]
|
||||
}, onCreated);
|
||||
title: chrome.i18n.getMessage('resurrect' + i18n) + context,
|
||||
}, logLastError);
|
||||
|
||||
addResurrectItem(context, 'Google', 'google', 'google');
|
||||
addResurrectItem(context, 'GoogleText', 'google-text', 'google');
|
||||
addResurrectItem(context, 'Archive', 'archive', 'waybackmachine');
|
||||
addResurrectItem(context, 'ArchiveIs', 'archiveis', 'archiveis');
|
||||
addResurrectItem(context, 'Webcitation', 'webcitation', 'webcitation');
|
||||
addResurrectItem(context, 'IsUp', 'isup', 'isup');
|
||||
chrome.contextMenus.create({
|
||||
enabled: false,
|
||||
id: 'resurrect-' + where + '-' + context,
|
||||
parentId: 'resurrect-' + context,
|
||||
title: chrome.i18n.getMessage('resurrectConfig' + i18n),
|
||||
});
|
||||
|
||||
for (let [name, id, icon] of [
|
||||
['Google', 'google', 'google'],
|
||||
['Google (text only)', 'googletext', 'google'],
|
||||
['The Internet Archive', 'archive', 'waybackmachine'],
|
||||
['The Internet Archive (list all)', 'archivelist', 'waybackmachine'],
|
||||
['archive.is', 'archiveis', 'archiveis'],
|
||||
['WebCite', 'webcitation', 'webcitation'],
|
||||
['Memento Timetravel', 'mementoweb', 'mementoweb'],
|
||||
['isup.me', 'IsUp', 'isup'],
|
||||
]) {
|
||||
chrome.contextMenus.create({
|
||||
contexts: [context],
|
||||
icons: {16: 'icons/cacheicons/' + icon + '.png'},
|
||||
id: 'resurrect-' + id + '-' + context,
|
||||
parentId: 'resurrect-' + context,
|
||||
title: chrome.i18n.getMessage('resurrect_' + context),
|
||||
}, logLastError);
|
||||
}
|
||||
|
||||
chrome.contextMenus.create({
|
||||
id: 'resurrect-separator-config-' + context,
|
||||
type: 'separator',
|
||||
contexts: [context],
|
||||
parentId: 'resurrect-' + context
|
||||
}, onCreated);
|
||||
}, logLastError);
|
||||
|
||||
addConfigItem(
|
||||
context, 'CurrentTab', 'current-tab', openIn == openInEnum.CURRENT_TAB);
|
||||
addConfigItem(
|
||||
context, 'NewTab', 'new-tab', openIn == openInEnum.NEW_TAB);
|
||||
addConfigItem(
|
||||
context, 'BgTab', 'bg-tab', openIn == openInEnum.BG_TAB);
|
||||
addConfigItem(
|
||||
context, 'NewWindow', 'new-window', openIn == openInEnum.NEW_WINDOW);
|
||||
chrome.contextMenus.create({
|
||||
enabled: false,
|
||||
id: 'resurrect-in-' + context,
|
||||
parentId: 'resurrect-' + context,
|
||||
title: 'In:',
|
||||
});
|
||||
|
||||
for (let [name, where, checked] of [
|
||||
['the current tab', 'current-tab', openIn == openInEnum.CURRENT_TAB],
|
||||
['a new tab (foreground)', 'new-tab', openIn == openInEnum.NEW_TAB],
|
||||
['a new tab (background)', 'bg-tab', openIn == openInEnum.NEW_BGTAB],
|
||||
['a new window', 'new-window', openIn == openInEnum.NEW_WINDOW],
|
||||
]) {
|
||||
chrome.contextMenus.create({
|
||||
id: 'resurrect-' + where + '-' + context,
|
||||
type: 'radio',
|
||||
title: name,
|
||||
contexts: [context],
|
||||
checked: checked,
|
||||
parentId: 'resurrect-' + context
|
||||
}, logLastError);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
||||
let id = info.menuItemId;
|
||||
let url = null;
|
||||
|
@ -68,19 +76,22 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
|||
} else if (id.endsWith('-link')) {
|
||||
url = info.linkUrl;
|
||||
}
|
||||
|
||||
if (id.startsWith('resurrect-google-')) {
|
||||
goToUrl(genGoogleUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-googletext-')) {
|
||||
goToUrl(genGoogleTextUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-archive-')) {
|
||||
goToUrl(genIaUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-archivelist-')) {
|
||||
goToUrl(genIaListUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-archiveis-')) {
|
||||
goToUrl(genArchiveIsUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-isup-')) {
|
||||
goToUrl(genIsUpUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-webcitation-')) {
|
||||
goToUrl(genWebCiteUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-mementoweb-')) {
|
||||
goToUrl(genMementoUrl(url), openIn);
|
||||
} else if (id.startsWith('resurrect-current-tab-')) {
|
||||
setOpenIn(openInEnum.CURRENT_TAB);
|
||||
} else if (id.startsWith('resurrect-new-tab-')) {
|
||||
|
|
39
common.js
39
common.js
|
@ -12,25 +12,30 @@ chrome.storage.local.get('openIn', item => {
|
|||
}
|
||||
});
|
||||
|
||||
function onError(error) {
|
||||
function logLastError() {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error('Resurrect error: ', chrome.runtime.lastError);
|
||||
console.error('Resurrect error:', chrome.runtime.lastError);
|
||||
}
|
||||
}
|
||||
|
||||
function genGoogleUrl(url) {
|
||||
return 'https://www.google.com/search?q=cache:'+encodeURIComponent(url);
|
||||
return 'https://www.google.com/search?q=cache:' + encodeURIComponent(url);
|
||||
}
|
||||
|
||||
function genGoogleTextUrl(url) {
|
||||
return 'https://www.google.com/search?strip=1&q=cache:'+encodeURIComponent(url);
|
||||
return 'https://www.google.com/search?strip=1&q=cache:' + encodeURIComponent(url);
|
||||
}
|
||||
|
||||
function genIaUrl(url) {
|
||||
let dateStr =(new Date()).toISOString().replace(/-|T|:|\..*/g, '');
|
||||
let dateStr = (new Date()).toISOString().replace(/-|T|:|\..*/g, '');
|
||||
return 'https://web.archive.org/web/'+dateStr+'/'+url;
|
||||
}
|
||||
|
||||
function genIaListUrl(url) {
|
||||
let dateStr = (new Date()).toISOString().replace(/-|T|:|\..*/g, '');
|
||||
return 'https://web.archive.org/web/*/'+url;
|
||||
}
|
||||
|
||||
function genArchiveIsUrl(url) {
|
||||
return 'https://archive.is/'+url;
|
||||
}
|
||||
|
@ -39,30 +44,36 @@ function genWebCiteUrl(url) {
|
|||
return 'http://webcitation.org/query.php?url='+encodeURIComponent(url);
|
||||
}
|
||||
|
||||
function genMementoUrl(url) {
|
||||
let dateStr = (new Date()).toISOString().replace(/-|T|:|\..*/g, '');
|
||||
return 'http://timetravel.mementoweb.org/list/'
|
||||
+ dateStr + '/' +url;
|
||||
}
|
||||
|
||||
function genIsUpUrl(url) {
|
||||
return 'http://isup.me/'+url;
|
||||
}
|
||||
|
||||
function setOpenIn(where) {
|
||||
openIn = where;
|
||||
chrome.storage.local.set({openIn: openIn}, onError);
|
||||
chrome.storage.local.set({openIn: openIn}, logLastError);
|
||||
updateContextRadios();
|
||||
}
|
||||
|
||||
function updateContextRadios() {
|
||||
['page', 'link'].forEach(context => {
|
||||
chrome.contextMenus.update(
|
||||
'resurrect-current-tab-' + context,
|
||||
{checked: openIn == openInEnum.CURRENT_TAB});
|
||||
'resurrect-current-tab-' + context,
|
||||
{checked: openIn == openInEnum.CURRENT_TAB});
|
||||
chrome.contextMenus.update(
|
||||
'resurrect-new-tab-' + context,
|
||||
{checked: openIn == openInEnum.NEW_TAB});
|
||||
'resurrect-new-tab-' + context,
|
||||
{checked: openIn == openInEnum.NEW_TAB});
|
||||
chrome.contextMenus.update(
|
||||
'resurrect-bg-tab-' + context,
|
||||
{checked: openIn == openInEnum.NEW_BGTAB});
|
||||
'resurrect-bg-tab-' + context,
|
||||
{checked: openIn == openInEnum.NEW_BGTAB});
|
||||
chrome.contextMenus.update(
|
||||
'resurrect-new-window-' + context,
|
||||
{checked: openIn == openInEnum.NEW_WINDOW});
|
||||
'resurrect-new-window-' + context,
|
||||
{checked: openIn == openInEnum.NEW_WINDOW});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "__MSG_extensionName__",
|
||||
"short_name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"version": "5",
|
||||
"version": "6",
|
||||
"default_locale": "en",
|
||||
"homepage_url": "https://github.com/Albirew/resurrect-pages",
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ label {
|
|||
}
|
||||
img {
|
||||
vertical-align: bottom;
|
||||
height: 16px;
|
||||
}
|
||||
</style>
|
||||
<form>
|
||||
|
@ -30,17 +31,23 @@ img {
|
|||
<button data-locale="resurrectArchive" data-gen="genIaUrl">
|
||||
<img src="icons/cacheicons/waybackmachine.png">
|
||||
</button>
|
||||
<button data-locale="resurrectArchiveList" data-gen="genIaListUrl">
|
||||
<img src="icons/cacheicons/waybackmachine.png">
|
||||
</button>
|
||||
<button data-locale="resurrectArchiveIs" data-gen="genArchiveIsUrl">
|
||||
<img src="icons/cacheicons/archiveis.png">
|
||||
</button>
|
||||
<button data-locale="resurrectWebcitation" data-gen="genWebCiteUrl">
|
||||
<img src="icons/cacheicons/webcitation.png">
|
||||
</button>
|
||||
<button data-locale="resurrectMementoWeb" data-gen="genMementoUrl">
|
||||
<img src="icons/cacheicons/mementoweb.png">
|
||||
</button>
|
||||
<button data-locale="resurrectIsUp" data-gen="genIsUpUrl">
|
||||
<img src="icons/cacheicons/isup.png">
|
||||
</button>
|
||||
|
||||
<br>
|
||||
<div style='line-height: 8px;'> </div>
|
||||
|
||||
<label data-locale="resurrectConfigCurrentTab">
|
||||
<input type="radio" name="openIn" value="0">
|
||||
|
|
6
popup.js
6
popup.js
|
@ -23,11 +23,15 @@ document.querySelectorAll('input[type=radio]').forEach(el => {
|
|||
function resurrect(gen) {
|
||||
return function() {
|
||||
chrome.tabs.query({active: true, currentWindow: true}, tabObj => {
|
||||
goToUrl(gen(tabObj[0].url), openIn);
|
||||
logLastError();
|
||||
let url = gen(tabObj[0].url);
|
||||
console.info('Resurrecting via URL', url);
|
||||
goToUrl(url, openIn);
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('button').forEach(el => {
|
||||
el.addEventListener(
|
||||
'click', resurrect(window[el.getAttribute('data-gen')]), true);
|
||||
|
|
Loading…
Reference in a new issue