Updated with latest version from Arrantius

- Add "list all versions" for The Internet Archive.
- Add MementoWeb TimeTravel source.

-Updated translation
Cette révision appartient à :
Albirew 2018-03-29 19:09:11 +02:00
Parent 71975d7125
révision e0155d5ab6
8 fichiers modifiés avec 121 ajouts et 62 suppressions

Voir le fichier

@ -10,11 +10,12 @@ Or, the easier route, use this extension.
## Features ## Features
* Searches through seven page cache/mirrors: * Searches through six page cache/mirrors:
* [Google Cache](http://www.google.com/) (plus text-only version) * [Google Cache](http://www.google.com/) (plus text-only version)
* [The Internet Archive](http://web.archive.org/) * [The Internet Archive](http://web.archive.org/)
* [WebCite](http://www.webcitation.org/) * [WebCite](http://www.webcitation.org/)
* [archive.is](https://archive.is/) * [archive.is](https://archive.is/)
* [Memento Time Travel](http://timetravel.mementoweb.org/)
* [Down for everyone?](http://www.isup.me/) * [Down for everyone?](http://www.isup.me/)
Of course, not every page can be in every cache. 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` * With the keyboard: press `Ctrl-Shift-U`
# Changelog # Changelog
* Version 6
* Merged with latest version from Arrantius
* Add "list all versions" for The Internet Archive.
* Add MementoWeb TimeTravel source.
* Version 5 * Version 5
* Merged with WebExtensions version from Arrantius (#3 #10) * Merged with WebExtensions version from Arrantius (#3 #10)
* Does not include netError page ([not currently possible](http://bugzil.la/1376793)) * Does not include netError page ([not currently possible](http://bugzil.la/1376793))

Voir le fichier

@ -34,6 +34,11 @@
"description": "with The Internet Archive" "description": "with The Internet Archive"
}, },
"resurrectArchiveList": {
"message": "with The Internet Archive (list all)",
"description": "with The Internet Archive (list all)"
},
"resurrectArchiveIs": { "resurrectArchiveIs": {
"message": "with archive.is", "message": "with archive.is",
"description": "with archive.is" "description": "with archive.is"
@ -44,6 +49,11 @@
"description": "with WebCite" "description": "with WebCite"
}, },
"resurrectMementoWeb": {
"message": "with Memento Timetravel",
"description": "with Memento Timetravel"
},
"resurrectIsUp": { "resurrectIsUp": {
"message": "check if really down", "message": "check if really down",
"description": "with isup.me" "description": "with isup.me"

Voir le fichier

@ -34,6 +34,11 @@
"description": "with The Internet Archive" "description": "with The Internet Archive"
}, },
"resurrectArchiveList": {
"message": "avec l'Archive Internet (historique)",
"description": "with The Internet Archive (list all)"
},
"resurrectArchiveIs": { "resurrectArchiveIs": {
"message": "avec archive.is", "message": "avec archive.is",
"description": "with archive.is" "description": "with archive.is"
@ -44,6 +49,11 @@
"description": "with WebCite" "description": "with WebCite"
}, },
"resurrectMementoWeb": {
"message": "avec Memento Timetravel",
"description": "with Memento Timetravel"
},
"resurrectIsUp": { "resurrectIsUp": {
"message": "Vérifier si le site est mort", "message": "Vérifier si le site est mort",
"description": "with isup.me" "description": "with isup.me"

Voir le fichier

@ -1,65 +1,73 @@
function onCreated(n) {
}
chrome.storage.local.get('openIn', item => { chrome.storage.local.get('openIn', item => {
if (item.openIn) { if (item.openIn) {
openIn = 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 => { ['page', 'link'].forEach(context => {
chrome.contextMenus.create({ chrome.contextMenus.create({
contexts: [context],
id: 'resurrect-' + context, id: 'resurrect-' + context,
title: chrome.i18n.getMessage('resurrect_' + context), title: chrome.i18n.getMessage('resurrect' + i18n) + context,
contexts: [context] }, logLastError);
}, onCreated);
addResurrectItem(context, 'Google', 'google', 'google'); chrome.contextMenus.create({
addResurrectItem(context, 'GoogleText', 'google-text', 'google'); enabled: false,
addResurrectItem(context, 'Archive', 'archive', 'waybackmachine'); id: 'resurrect-' + where + '-' + context,
addResurrectItem(context, 'ArchiveIs', 'archiveis', 'archiveis'); parentId: 'resurrect-' + context,
addResurrectItem(context, 'Webcitation', 'webcitation', 'webcitation'); title: chrome.i18n.getMessage('resurrectConfig' + i18n),
addResurrectItem(context, 'IsUp', 'isup', 'isup'); });
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({ chrome.contextMenus.create({
id: 'resurrect-separator-config-' + context, id: 'resurrect-separator-config-' + context,
type: 'separator', type: 'separator',
contexts: [context], contexts: [context],
parentId: 'resurrect-' + context parentId: 'resurrect-' + context
}, onCreated); }, logLastError);
addConfigItem( chrome.contextMenus.create({
context, 'CurrentTab', 'current-tab', openIn == openInEnum.CURRENT_TAB); enabled: false,
addConfigItem( id: 'resurrect-in-' + context,
context, 'NewTab', 'new-tab', openIn == openInEnum.NEW_TAB); parentId: 'resurrect-' + context,
addConfigItem( title: 'In:',
context, 'BgTab', 'bg-tab', openIn == openInEnum.BG_TAB); });
addConfigItem(
context, 'NewWindow', 'new-window', openIn == openInEnum.NEW_WINDOW); 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) { chrome.contextMenus.onClicked.addListener(function(info, tab) {
let id = info.menuItemId; let id = info.menuItemId;
let url = null; let url = null;
@ -68,19 +76,22 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) {
} else if (id.endsWith('-link')) { } else if (id.endsWith('-link')) {
url = info.linkUrl; url = info.linkUrl;
} }
if (id.startsWith('resurrect-google-')) { if (id.startsWith('resurrect-google-')) {
goToUrl(genGoogleUrl(url), openIn); goToUrl(genGoogleUrl(url), openIn);
} else if (id.startsWith('resurrect-googletext-')) { } else if (id.startsWith('resurrect-googletext-')) {
goToUrl(genGoogleTextUrl(url), openIn); goToUrl(genGoogleTextUrl(url), openIn);
} else if (id.startsWith('resurrect-archive-')) { } else if (id.startsWith('resurrect-archive-')) {
goToUrl(genIaUrl(url), openIn); goToUrl(genIaUrl(url), openIn);
} else if (id.startsWith('resurrect-archivelist-')) {
goToUrl(genIaListUrl(url), openIn);
} else if (id.startsWith('resurrect-archiveis-')) { } else if (id.startsWith('resurrect-archiveis-')) {
goToUrl(genArchiveIsUrl(url), openIn); goToUrl(genArchiveIsUrl(url), openIn);
} else if (id.startsWith('resurrect-isup-')) { } else if (id.startsWith('resurrect-isup-')) {
goToUrl(genIsUpUrl(url), openIn); goToUrl(genIsUpUrl(url), openIn);
} else if (id.startsWith('resurrect-webcitation-')) { } else if (id.startsWith('resurrect-webcitation-')) {
goToUrl(genWebCiteUrl(url), openIn); goToUrl(genWebCiteUrl(url), openIn);
} else if (id.startsWith('resurrect-mementoweb-')) {
goToUrl(genMementoUrl(url), openIn);
} else if (id.startsWith('resurrect-current-tab-')) { } else if (id.startsWith('resurrect-current-tab-')) {
setOpenIn(openInEnum.CURRENT_TAB); setOpenIn(openInEnum.CURRENT_TAB);
} else if (id.startsWith('resurrect-new-tab-')) { } else if (id.startsWith('resurrect-new-tab-')) {

Voir le fichier

@ -12,25 +12,30 @@ chrome.storage.local.get('openIn', item => {
} }
}); });
function onError(error) { function logLastError() {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
console.error('Resurrect error: ', chrome.runtime.lastError); console.error('Resurrect error:', chrome.runtime.lastError);
} }
} }
function genGoogleUrl(url) { 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) { 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) { 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; 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) { function genArchiveIsUrl(url) {
return 'https://archive.is/'+url; return 'https://archive.is/'+url;
} }
@ -39,30 +44,36 @@ function genWebCiteUrl(url) {
return 'http://webcitation.org/query.php?url='+encodeURIComponent(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) { function genIsUpUrl(url) {
return 'http://isup.me/'+url; return 'http://isup.me/'+url;
} }
function setOpenIn(where) { function setOpenIn(where) {
openIn = where; openIn = where;
chrome.storage.local.set({openIn: openIn}, onError); chrome.storage.local.set({openIn: openIn}, logLastError);
updateContextRadios(); updateContextRadios();
} }
function updateContextRadios() { function updateContextRadios() {
['page', 'link'].forEach(context => { ['page', 'link'].forEach(context => {
chrome.contextMenus.update( chrome.contextMenus.update(
'resurrect-current-tab-' + context, 'resurrect-current-tab-' + context,
{checked: openIn == openInEnum.CURRENT_TAB}); {checked: openIn == openInEnum.CURRENT_TAB});
chrome.contextMenus.update( chrome.contextMenus.update(
'resurrect-new-tab-' + context, 'resurrect-new-tab-' + context,
{checked: openIn == openInEnum.NEW_TAB}); {checked: openIn == openInEnum.NEW_TAB});
chrome.contextMenus.update( chrome.contextMenus.update(
'resurrect-bg-tab-' + context, 'resurrect-bg-tab-' + context,
{checked: openIn == openInEnum.NEW_BGTAB}); {checked: openIn == openInEnum.NEW_BGTAB});
chrome.contextMenus.update( chrome.contextMenus.update(
'resurrect-new-window-' + context, 'resurrect-new-window-' + context,
{checked: openIn == openInEnum.NEW_WINDOW}); {checked: openIn == openInEnum.NEW_WINDOW});
}); });
} }

Voir le fichier

@ -3,7 +3,7 @@
"name": "__MSG_extensionName__", "name": "__MSG_extensionName__",
"short_name": "__MSG_extensionName__", "short_name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__", "description": "__MSG_extensionDescription__",
"version": "5", "version": "6",
"default_locale": "en", "default_locale": "en",
"homepage_url": "https://github.com/Albirew/resurrect-pages", "homepage_url": "https://github.com/Albirew/resurrect-pages",

Voir le fichier

@ -18,6 +18,7 @@ label {
} }
img { img {
vertical-align: bottom; vertical-align: bottom;
height: 16px;
} }
</style> </style>
<form> <form>
@ -30,17 +31,23 @@ img {
<button data-locale="resurrectArchive" data-gen="genIaUrl"> <button data-locale="resurrectArchive" data-gen="genIaUrl">
<img src="icons/cacheicons/waybackmachine.png"> <img src="icons/cacheicons/waybackmachine.png">
</button> </button>
<button data-locale="resurrectArchiveList" data-gen="genIaListUrl">
<img src="icons/cacheicons/waybackmachine.png">
</button>
<button data-locale="resurrectArchiveIs" data-gen="genArchiveIsUrl"> <button data-locale="resurrectArchiveIs" data-gen="genArchiveIsUrl">
<img src="icons/cacheicons/archiveis.png"> <img src="icons/cacheicons/archiveis.png">
</button> </button>
<button data-locale="resurrectWebcitation" data-gen="genWebCiteUrl"> <button data-locale="resurrectWebcitation" data-gen="genWebCiteUrl">
<img src="icons/cacheicons/webcitation.png"> <img src="icons/cacheicons/webcitation.png">
</button> </button>
<button data-locale="resurrectMementoWeb" data-gen="genMementoUrl">
<img src="icons/cacheicons/mementoweb.png">
</button>
<button data-locale="resurrectIsUp" data-gen="genIsUpUrl"> <button data-locale="resurrectIsUp" data-gen="genIsUpUrl">
<img src="icons/cacheicons/isup.png"> <img src="icons/cacheicons/isup.png">
</button> </button>
<br> <div style='line-height: 8px;'>&nbsp;</div>
<label data-locale="resurrectConfigCurrentTab"> <label data-locale="resurrectConfigCurrentTab">
<input type="radio" name="openIn" value="0"> <input type="radio" name="openIn" value="0">

Voir le fichier

@ -23,11 +23,15 @@ document.querySelectorAll('input[type=radio]').forEach(el => {
function resurrect(gen) { function resurrect(gen) {
return function() { return function() {
chrome.tabs.query({active: true, currentWindow: true}, tabObj => { 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(); window.close();
}); });
} }
} }
document.querySelectorAll('button').forEach(el => { document.querySelectorAll('button').forEach(el => {
el.addEventListener( el.addEventListener(
'click', resurrect(window[el.getAttribute('data-gen')]), true); 'click', resurrect(window[el.getAttribute('data-gen')]), true);