1
1
Bifurcation 0

Generally rewrite the whole thing.

Consistent coding style, significantly less repetition.  Use `chrome` rather than `browser`, for compatibility.
Cette révision appartient à :
Anthony Lieuallen 2017-08-20 12:10:19 -04:00
Parent 9d3a93a1e2
révision 322eb9cd74
8 fichiers modifiés avec 242 ajouts et 473 suppressions

3
.gitignore externe Fichier normal
Voir le fichier

@ -0,0 +1,3 @@
*.xpi
.project
.settings

Voir le fichier

@ -1,19 +1,16 @@
# Resurrect Pages 4
## Documentation
# Documentation
Dead pages, broken links, the scourge of the internet.
Powerhouse sites like Slashdot and Digg can bring a server to its knees.
What do we do when a page is dead but we still want to see it?
Call in the clerics, and perform a resurrection ceremony!
Or, the easier route, use this extension.
Or (the easier route) use this extension.
## Screenshots
![Context Menu](https://camo.githubusercontent.com/264d0c9221bd3b22a41b3848597eeedbd606a5fb/68747470733a2f2f692e696d6775722e636f6d2f48654d666f77792e706e67)
![Toolbar Menu](https://camo.githubusercontent.com/973154dcbc6c17736b9b2d4e4a4a00959465ec6d/68747470733a2f2f692e696d6775722e636f6d2f6d4c554e52414c2e706e67)
## Features
* Searches through seven page cache/mirrors:
@ -31,14 +28,13 @@ Hit back and try another one!
* In the toolbar, just customize it to drag the button in.
* With the keyboard: press `Ctrl-Shift-U`
# Changelog
* Version 4.1 (Aug 20, 2017)
* includes toolbar icon with popup, keyboard shortcut
* does not include netError page ([not possible currently](https://bugzilla.mozilla.org/show_bug.cgi?id=1376793))
* Version 4 (Aug 19, 2017)
* completely rewritten as WebExtension by [Tobias Girstmair](https://gir.st/)
* Version 4 (**pending release**)
* Rewritten as WebExtension with major contributions
by [Tobias Girstmair](https://gir.st/)
* Does not include netError page
([not possible currently](http://bugzil.la/1376793))
* Not everything from the old version ported over yet
* Version 3 (Sep 9, 2015)
* Fix layout on error page w.r.t. the "report error" dialog.

Voir le fichier

@ -9,64 +9,58 @@
"description": "Description of the add-on."
},
"contextMenuItemResurrectPage": {
"resurrect_page": {
"message": "Resurrect this page",
"description": "Resurrect this page"
},
"contextMenuItemResurrectLink": {
"resurrect_link": {
"message": "Resurrect this link",
"description": "Resurrect this link"
},
"contextMenuItemResurrectSelection": {
"message": "Resurrect this selection",
"description": "Resurrect this selection, TODO: only if its a link"
},
"contextMenuItemResurrectGoogle": {
"resurrectGoogle": {
"message": "with Google",
"description": "with Google"
},
"contextMenuItemResurrectGoogleText": {
"resurrectGoogleText": {
"message": "with Google (text only)",
"description": "with Google (text only)"
},
"contextMenuItemResurrectArchive": {
"resurrectArchive": {
"message": "with The Internet Archive",
"description": "with The Internet Archive"
},
"contextMenuItemResurrectArchiveIs": {
"resurrectArchiveIs": {
"message": "with archive.is",
"description": "with archive.is"
},
"contextMenuItemResurrectWebcitation": {
"resurrectWebcitation": {
"message": "with WebCite",
"description": "with WebCite"
},
"contextMenuItemResurrectConfigCurrentTab": {
"resurrectConfigCurrentTab": {
"message": "in the current tab",
"description": "in the current tab"
},
"contextMenuItemResurrectConfigNewTab": {
"resurrectConfigNewTab": {
"message": "in a new tab (foreground)",
"description": "in a new tab (foreground)"
},
"contextMenuItemResurrectConfigNewBackgroundTab": {
"resurrectConfigBgTab": {
"message": "in a new tab (background)",
"description": "in a new tab (background)"
},
"contextMenuItemResurrectConfigNewWindow": {
"resurrectConfigNewWindow": {
"message": "in a new window",
"description": "in a new window"
}
}

Voir le fichier

@ -1,343 +1,91 @@
var openIn = openInEnum.CURRENT_TAB;
browser.storage.local.get ("openIn").then (function (item) {
if (item.openIn) {openIn = item.openIn}
/*
Create all the context menu items.
*/
// top level {{{
browser.contextMenus.create({
id: "resurrect-page",
title: browser.i18n.getMessage("contextMenuItemResurrectPage"),
contexts: ["page"]
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link",
title: browser.i18n.getMessage("contextMenuItemResurrectLink"),
contexts: ["link"]
}, onCreated);
browser.contextMenus.create({
id: "resurrect-selection",
title: browser.i18n.getMessage("contextMenuItemResurrectSelection"),
contexts: ["selection"]
}, onCreated);
//}}}
// resurrect page {{{
browser.contextMenus.create({
id: "resurrect-page-google",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogle"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-googletext",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogleText"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-archive",
title: browser.i18n.getMessage("contextMenuItemResurrectArchive"),
icons: { 16: "icons/cacheicons/waybackmachine.png" },
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-archiveis",
title: browser.i18n.getMessage("contextMenuItemResurrectArchiveIs"),
icons: { 16: "icons/cacheicons/archiveis.png" },
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-webcitation",
title: browser.i18n.getMessage("contextMenuItemResurrectWebcitation"),
icons: { 16: "icons/cacheicons/webcitation.png" },
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
//}}}
// resurrect link {{{
browser.contextMenus.create({
id: "resurrect-link-google",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogle"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-googletext",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogleText"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-archive",
title: browser.i18n.getMessage("contextMenuItemResurrectArchive"),
icons: { 16: "icons/cacheicons/waybackmachine.png" },
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-archiveis",
title: browser.i18n.getMessage("contextMenuItemResurrectArchiveIs"),
icons: { 16: "icons/cacheicons/archiveis.png" },
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-webcitation",
title: browser.i18n.getMessage("contextMenuItemResurrectWebcitation"),
icons: { 16: "icons/cacheicons/webcitation.png" },
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
//}}}
// resurrect selection {{{
browser.contextMenus.create({
id: "resurrect-slct-google",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogle"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-googletext",
title: browser.i18n.getMessage("contextMenuItemResurrectGoogleText"),
icons: { 16: "icons/cacheicons/google.png" },
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-archive",
title: browser.i18n.getMessage("contextMenuItemResurrectArchive"),
icons: { 16: "icons/cacheicons/waybackmachine.png" },
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-archiveis",
title: browser.i18n.getMessage("contextMenuItemResurrectArchiveIs"),
icons: { 16: "icons/cacheicons/archiveis.png" },
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-webcitation",
title: browser.i18n.getMessage("contextMenuItemResurrectWebcitation"),
icons: { 16: "icons/cacheicons/webcitation.png" },
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
//}}}
//config page {{{
browser.contextMenus.create({
id: "separator-1",
type: "separator",
contexts: ["all"],
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-current-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigCurrentTab"),
contexts: ["all"],
checked: openIn==openInEnum.CURRENT_TAB,
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-new-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_TAB,
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-new-background-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewBackgroundTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_BGTAB,
parentId: "resurrect-page"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-page-new-window",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewWindow"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_WINDOW,
parentId: "resurrect-page"
}, onCreated);
//}}}
//config link {{{
browser.contextMenus.create({
id: "separator-2",
type: "separator",
contexts: ["all"],
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-current-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigCurrentTab"),
contexts: ["all"],
checked: openIn==openInEnum.CURRENT_TAB,
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-new-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_TAB,
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-new-background-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewBackgroundTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_BGTAB,
parentId: "resurrect-link"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-link-new-window",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewWindow"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_WINDOW,
parentId: "resurrect-link"
}, onCreated);
//}}}
//config selection {{{
browser.contextMenus.create({
id: "separator-3",
type: "separator",
contexts: ["all"],
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-current-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigCurrentTab"),
contexts: ["all"],
checked: openIn==openInEnum.CURRENT_TAB,
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-new-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_TAB,
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-new-background-tab",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewBackgroundTab"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_BGTAB,
parentId: "resurrect-selection"
}, onCreated);
browser.contextMenus.create({
id: "resurrect-slct-new-window",
type: "radio",
title: browser.i18n.getMessage("contextMenuItemResurrectConfigNewWindow"),
contexts: ["all"],
checked: openIn==openInEnum.NEW_WINDOW,
parentId: "resurrect-selection"
}, onCreated);
//}}}
}, onError);
function onCreated(n) {
if (browser.runtime.lastError) {
console.log('Error: '+browser.runtime.lastError);
}
}
browser.contextMenus.onClicked.addListener(function(info, tab) {
var gotoUrl=null;
var rawUrl = info.pageUrl;
chrome.storage.local.get('openIn', item => {
if (item.openIn) {
openIn = item.openIn;
}
switch (info.menuItemId) {
case "resurrect-page-google": goToURL (genGoogleURL(info.pageUrl), openIn); break;
case "resurrect-link-google": goToURL (genGoogleURL(info.linkUrl), openIn); break;
case "resurrect-slct-google": goToURL (genGoogleURL(info.selectionText), openIn); break;
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);
}
case "resurrect-page-googletext": goToURL (genGoogleTextURL(info.pageUrl), openIn); break;
case "resurrect-link-googletext": goToURL (genGoogleTextURL(info.linkUrl), openIn); break;
case "resurrect-slct-googletext": goToURL (genGoogleTextURL(info.selectionText), openIn); break;
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);
}
case "resurrect-page-archive": goToURL (genIAURL(info.pageUrl), openIn); break;
case "resurrect-link-archive": goToURL (genIAURL(info.linkUrl), openIn); break;
case "resurrect-slct-archive": goToURL (genIAURL(info.selectionText), openIn); break;
['page', 'link'].forEach(context => {
chrome.contextMenus.create({
id: 'resurrect-' + context,
title: chrome.i18n.getMessage('resurrect_' + context),
contexts: [context]
}, onCreated);
case "resurrect-page-archiveis": goToURL (genArchiveIsURL(info.pageUrl), openIn); break;
case "resurrect-link-archiveis": goToURL (genArchiveIsURL(info.linkUrl), openIn); break;
case "resurrect-slct-archiveis": goToURL (genArchiveIsURL(info.selectionText), openIn); break;
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');
case "resurrect-page-webcitation": goToURL (genWebCiteURL(info.pageUrl), openIn); break;
case "resurrect-link-webcitation": goToURL (genWebCiteURL(info.linkUrl), openIn); break;
case "resurrect-slct-webcitation": goToURL (genWebCiteURL(info.selectionText), openIn); break;
chrome.contextMenus.create({
id: 'resurrect-separator-config-' + context,
type: 'separator',
contexts: [context],
parentId: 'resurrect-' + context
}, onCreated);
case "resurrect-page-current-tab":
case "resurrect-link-current-tab":
case "resurrect-slct-current-tab":
setOpenIn (openInEnum.CURRENT_TAB);
return;
case "resurrect-page-new-tab":
case "resurrect-link-new-tab":
case "resurrect-slct-new-tab":
setOpenIn (openInEnum.NEW_TAB);
return;
case "resurrect-page-new-background-tab":
case "resurrect-link-new-background-tab":
case "resurrect-slct-new-background-tab":
setOpenIn (openInEnum.NEW_BGTAB);
return;
case "resurrect-page-new-window":
case "resurrect-link-new-window":
case "resurrect-slct-new-window":
setOpenIn (openInEnum.NEW_WINDOW);
return;
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.onClicked.addListener(function(info, tab) {
let id = info.menuItemId;
let url = null;
if (id.endsWith('-page')) {
url = info.pageUrl;
} 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-archiveis-')) {
goToUrl(genArchiveIsUrl(url), openIn);
} else if (id.startsWith('resurrect-webcitation-')) {
goToUrl(genWebCiteUrl(url), openIn);
} else if (id.startsWith('resurrect-current-tab-')) {
setOpenIn(openInEnum.CURRENT_TAB);
} else if (id.startsWith('resurrect-new-tab-')) {
setOpenIn(openInEnum.NEW_TAB);
} else if (id.startsWith('resurrect-new-bg-tab-')) {
setOpenIn(openInEnum.NEW_BGTAB);
} else if (id.startsWith('resurrect-new-window-')) {
setOpenIn(openInEnum.NEW_WINDOW);
}
});

Voir le fichier

@ -4,71 +4,83 @@ openInEnum = {
NEW_BGTAB : 2,
NEW_WINDOW : 3
}
let openIn = openInEnum.CURRENT_TAB;
chrome.storage.local.get('openIn', item => {
if (item.openIn) {
openIn = item.openIn;
}
});
var openIn = openInEnum.CURRENT_TAB;
browser.storage.local.get ("openIn").then (function (item) { if (item.openIn) {openIn = item.openIn} }, onError);
function onError(error) {
console.log('Error: '+error);
if (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);
}
function genGoogleTextURL (url) {
function genGoogleTextUrl(url) {
return 'https://www.google.com/search?strip=1&q=cache:'+encodeURIComponent(url);
}
function genIAURL (url) {
var dateStr = (new Date()).toISOString().replace(/-|T|:|\..*/g, '');
function genIaUrl(url) {
let dateStr =(new Date()).toISOString().replace(/-|T|:|\..*/g, '');
return 'https://web.archive.org/web/'+dateStr+'/'+url;
}
function genArchiveIsURL (url) {
function genArchiveIsUrl(url) {
return 'https://archive.is/'+url;
}
function genWebCiteURL (url) {
function genWebCiteUrl(url) {
return 'http://webcitation.org/query.php?url='+encodeURIComponent(url);
}
function setOpenIn (where) {
function setOpenIn(where) {
openIn = where;
browser.storage.local.set({openIn: openIn}).then(null, onError);
update_context_radios();
chrome.storage.local.set({openIn: openIn}, onError);
updateContextRadios();
}
function update_context_radios() {
browser.contextMenus.update ("resurrect-page-current-tab" , {checked: openIn==openInEnum.CURRENT_TAB});
browser.contextMenus.update ("resurrect-page-new-tab" , {checked: openIn==openInEnum.NEW_TAB});
browser.contextMenus.update ("resurrect-page-new-background-tab", {checked: openIn==openInEnum.NEW_BGTAB});
browser.contextMenus.update ("resurrect-page-new-window" , {checked: openIn==openInEnum.NEW_WINDOW});
browser.contextMenus.update ("resurrect-link-current-tab" , {checked: openIn==openInEnum.CURRENT_TAB});
browser.contextMenus.update ("resurrect-link-new-tab" , {checked: openIn==openInEnum.NEW_TAB});
browser.contextMenus.update ("resurrect-link-new-background-tab", {checked: openIn==openInEnum.NEW_BGTAB});
browser.contextMenus.update ("resurrect-link-new-window" , {checked: openIn==openInEnum.NEW_WINDOW});
browser.contextMenus.update ("resurrect-slct-current-tab" , {checked: openIn==openInEnum.CURRENT_TAB});
browser.contextMenus.update ("resurrect-slct-new-tab" , {checked: openIn==openInEnum.NEW_TAB});
browser.contextMenus.update ("resurrect-slct-new-background-tab", {checked: openIn==openInEnum.NEW_BGTAB});
browser.contextMenus.update ("resurrect-slct-new-window" , {checked: openIn==openInEnum.NEW_WINDOW});
function updateContextRadios() {
['page', 'link'].forEach(context => {
chrome.contextMenus.update(
'resurrect-current-tab-' + context,
{checked: openIn == openInEnum.CURRENT_TAB});
chrome.contextMenus.update(
'resurrect-new-tab-' + context,
{checked: openIn == openInEnum.NEW_TAB});
chrome.contextMenus.update(
'resurrect-new-bg-tab-' + context,
{checked: openIn == openInEnum.NEW_BGTAB});
chrome.contextMenus.update(
'resurrect-new-window-' + context,
{checked: openIn == openInEnum.NEW_WINDOW});
});
}
function goToURL (url, where) {
switch (Number(where)) {
case openInEnum.CURRENT_TAB:
browser.tabs.update({ "url": url});
break;
case openInEnum.NEW_TAB:
browser.tabs.create({ "url": url});
break;
case openInEnum.NEW_BGTAB:
browser.tabs.create({ "url": url, "active":false});
break;
case openInEnum.NEW_WINDOW:
browser.windows.create({ "url": url});
break;
function goToUrl(url, where) {
switch(Number(where)) {
case openInEnum.CURRENT_TAB:
chrome.tabs.update({'url': url});
break;
case openInEnum.NEW_TAB:
chrome.tabs.create({'url': url});
break;
case openInEnum.NEW_BGTAB:
chrome.tabs.create({'url': url, 'active': false});
break;
case openInEnum.NEW_WINDOW:
chrome.windows.create({'url': url});
break;
}
}

Voir le fichier

@ -1,19 +1,22 @@
{
"manifest_version": 2,
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "4.1",
"version": "4",
"default_locale": "en",
"applications": {
"gecko": {
"id":"resurrect-pages@gir.st",
"id": "{0c8fbd76-bdeb-4c52-9b24-d587ce7b9dc3}",
"strict_min_version": "56.0b3"
}
},
"background": {
"scripts": ["common.js","background.js"]
"scripts": [
"common.js",
"background.js"
]
},
"browser_action": {
@ -21,12 +24,18 @@
"default_title": "__MSG_extensionName__",
"default_popup": "popup.htm"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+U"
}
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+U"
}
}
},
"icons": {
"16": "icons/page-16.png",
"32": "icons/page-32.png"
},
"permissions": [
@ -34,11 +43,5 @@
"contextMenus",
"tabs",
"activeTab"
],
"icons": {
"16": "icons/page-16.png",
"32": "icons/page-32.png"
}
]
}

Voir le fichier

@ -2,28 +2,55 @@
<meta charset="utf-8">
<style>
body {
font-family: sans-serif;
font-size: small;
font-family: caption, sans-serif;
}
button, label {
display: block;
width: 100%;
}
button {
width: 100%;
text-align:left;
margin: 2px 0;
padding: 2px;
text-align: left;
}
label {
font-size: small;
}
img {
vertical-align:bottom;
vertical-align: bottom;
}
</style>
<form>
<button id="resurrectWithGoogle" ><img src="icons/cacheicons/google.png"> <span id="lgo"></span></button><br>
<button id="resurrectWithGoogleText" ><img src="icons/cacheicons/google.png"> <span id="lgt"></span></button><br>
<button id="resurrectWithInternetArchive"><img src="icons/cacheicons/waybackmachine.png"> <span id="lia"></span></button><br>
<button id="resurrectWithArchiveIs" ><img src="icons/cacheicons/archiveis.png"> <span id="lai"></span></button><br>
<button id="resurrectWithWebCite" ><img src="icons/cacheicons/webcitation.png"> <span id="lwc"></span></button><br>
<hr>
<input type="radio" name="openIn" value="0" id="current" ><label for="current" id="lc"></label></br>
<input type="radio" name="openIn" value="1" id="newtabfg"><label for="newtabfg" id="ltf"></label></br>
<input type="radio" name="openIn" value="2" id="newtabbg"><label for="newtabbg" id="ltb"></label></br>
<input type="radio" name="openIn" value="3" id="newwin" ><label for="newwin" id="lw"></label></br>
<button data-locale="resurrectGoogle" data-gen="genGoogleUrl">
<img src="icons/cacheicons/google.png">
</button>
<button data-locale="resurrectGoogleText" data-gen="genGoogleTextUrl">
<img src="icons/cacheicons/google.png">
</button>
<button data-locale="resurrectArchive" data-gen="genIaUrl">
<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>
<br>
<label data-locale="resurrectConfigCurrentTab">
<input type="radio" name="openIn" value="0">
</label>
<label data-locale="resurrectConfigNewTab">
<input type="radio" name="openIn" value="1">
</label>
<label data-locale="resurrectConfigBgTab">
<input type="radio" name="openIn" value="2">
</label>
<label data-locale="resurrectConfigNewWindow">
<input type="radio" name="openIn" value="3">
</label>
</form>
<script src="common.js"></script>

Voir le fichier

@ -1,46 +1,32 @@
document.addEventListener('DOMContentLoaded', function() {
browser.storage.local.get ("openIn").then(function(res) {
switch (Number(res.openIn)) {
case openInEnum.CURRENT_TAB:
document.querySelector("#current").checked = true;
break;
case openInEnum.NEW_TAB:
document.querySelector("#newtabfg").checked = true;
break;
case openInEnum.NEW_BGTAB:
document.querySelector("#newtabbg").checked = true;
break;
case openInEnum.NEW_WINDOW:
document.querySelector("#newwin").checked = true;
break;
default:
document.querySelector("#current").checked = true;
onError("can't read openIn");
}
chrome.storage.local.get('openIn', res => {
document.querySelectorAll('input[type=radio]').forEach(el => {
el.checked = el.value == res.openIn;
});
document.querySelector("#lc").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectConfigCurrentTab");
document.querySelector("#ltf").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectConfigNewTab");
document.querySelector("#ltb").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectConfigNewBackgroundTab");
document.querySelector("#lw").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectConfigNewWindow");
document.querySelector("#current").onchange = function(){setOpenIn(document.querySelector('input[name="openIn"]:checked').value)};
document.querySelector("#newtabfg").onchange = function(){setOpenIn(document.querySelector('input[name="openIn"]:checked').value)};
document.querySelector("#newtabbg").onchange = function(){setOpenIn(document.querySelector('input[name="openIn"]:checked').value)};
document.querySelector("#newwin").onchange = function(){setOpenIn(document.querySelector('input[name="openIn"]:checked').value)};
document.querySelector("#lgo").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectGoogle");
document.querySelector("#lgt").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectGoogleText");
document.querySelector("#lia").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectArchive");
document.querySelector("#lai").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectArchiveIs");
document.querySelector("#lwc").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectWebcitation");
browser.tabs.query({active:true,currentWindow:true}).then(function(tabObj){
pageURL = tabObj[0].url;
document.querySelector("#resurrectWithGoogle").onclick = function(){goToURL (genGoogleURL (pageURL), openIn);window.close()};
document.querySelector("#resurrectWithGoogleText").onclick = function(){goToURL (genGoogleTextURL(pageURL), openIn);window.close()};
document.querySelector("#resurrectWithInternetArchive").onclick = function(){goToURL (genIAURL (pageURL), openIn);window.close()};
document.querySelector("#resurrectWithArchiveIs").onclick = function(){goToURL (genArchiveIsURL (pageURL), openIn);window.close()};
document.querySelector("#resurrectWithWebCite").onclick = function(){goToURL (genWebCiteURL (pageURL), openIn);window.close()};
}, onError);
});
document.querySelectorAll('*[data-locale]').forEach(el => {
el.innerHTML += ' ' + chrome.i18n.getMessage(el.getAttribute('data-locale'));
});
function onOpenInChange() {
setOpenIn(document.querySelector('input[name="openIn"]:checked').value);
};
document.querySelectorAll('input[type=radio]').forEach(el => {
el.addEventListener('click', onOpenInChange, true);
});
function resurrect(gen) {
return function() {
chrome.tabs.query({active: true, currentWindow: true}, tabObj => {
goToUrl(gen(tabObj[0].url), openIn);
window.close();
});
}
}
document.querySelectorAll('button').forEach(el => {
el.addEventListener(
'click', resurrect(window[el.getAttribute('data-gen')]), true);
});