Generally rewrite the whole thing.
Consistent coding style, significantly less repetition. Use `chrome` rather than `browser`, for compatibility.
Cette révision appartient à :
Parent
9d3a93a1e2
révision
322eb9cd74
8 fichiers modifiés avec 242 ajouts et 473 suppressions
3
.gitignore
externe
Fichier normal
3
.gitignore
externe
Fichier normal
|
@ -0,0 +1,3 @@
|
||||||
|
*.xpi
|
||||||
|
.project
|
||||||
|
.settings
|
18
README.md
18
README.md
|
@ -1,19 +1,16 @@
|
||||||
# Resurrect Pages 4
|
# Documentation
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
Dead pages, broken links, the scourge of the internet.
|
Dead pages, broken links, the scourge of the internet.
|
||||||
Powerhouse sites like Slashdot and Digg can bring a server to its knees.
|
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?
|
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!
|
Call in the clerics, and perform a resurrection ceremony!
|
||||||
Or, the easier route, use this extension.
|
Or (the easier route) use this extension.
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
![Context Menu](https://camo.githubusercontent.com/264d0c9221bd3b22a41b3848597eeedbd606a5fb/68747470733a2f2f692e696d6775722e636f6d2f48654d666f77792e706e67)
|
![Context Menu](https://camo.githubusercontent.com/264d0c9221bd3b22a41b3848597eeedbd606a5fb/68747470733a2f2f692e696d6775722e636f6d2f48654d666f77792e706e67)
|
||||||
![Toolbar Menu](https://camo.githubusercontent.com/973154dcbc6c17736b9b2d4e4a4a00959465ec6d/68747470733a2f2f692e696d6775722e636f6d2f6d4c554e52414c2e706e67)
|
![Toolbar Menu](https://camo.githubusercontent.com/973154dcbc6c17736b9b2d4e4a4a00959465ec6d/68747470733a2f2f692e696d6775722e636f6d2f6d4c554e52414c2e706e67)
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Searches through seven page cache/mirrors:
|
* 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.
|
* In the toolbar, just customize it to drag the button in.
|
||||||
* With the keyboard: press `Ctrl-Shift-U`
|
* With the keyboard: press `Ctrl-Shift-U`
|
||||||
|
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
* Version 4.1 (Aug 20, 2017)
|
* Version 4 (**pending release**)
|
||||||
* includes toolbar icon with popup, keyboard shortcut
|
* Rewritten as WebExtension with major contributions
|
||||||
* does not include netError page ([not possible currently](https://bugzilla.mozilla.org/show_bug.cgi?id=1376793))
|
by [Tobias Girstmair](https://gir.st/)
|
||||||
* Version 4 (Aug 19, 2017)
|
* Does not include netError page
|
||||||
* completely rewritten as WebExtension by [Tobias Girstmair](https://gir.st/)
|
([not possible currently](http://bugzil.la/1376793))
|
||||||
* Not everything from the old version ported over yet
|
* Not everything from the old version ported over yet
|
||||||
* Version 3 (Sep 9, 2015)
|
* Version 3 (Sep 9, 2015)
|
||||||
* Fix layout on error page w.r.t. the "report error" dialog.
|
* Fix layout on error page w.r.t. the "report error" dialog.
|
||||||
|
|
|
@ -9,64 +9,58 @@
|
||||||
"description": "Description of the add-on."
|
"description": "Description of the add-on."
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectPage": {
|
"resurrect_page": {
|
||||||
"message": "Resurrect this page",
|
"message": "Resurrect this page",
|
||||||
"description": "Resurrect this page"
|
"description": "Resurrect this page"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectLink": {
|
"resurrect_link": {
|
||||||
"message": "Resurrect this link",
|
"message": "Resurrect this link",
|
||||||
"description": "Resurrect this link"
|
"description": "Resurrect this link"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectSelection": {
|
"resurrectGoogle": {
|
||||||
"message": "Resurrect this selection",
|
|
||||||
"description": "Resurrect this selection, TODO: only if its a link"
|
|
||||||
},
|
|
||||||
|
|
||||||
"contextMenuItemResurrectGoogle": {
|
|
||||||
"message": "with Google",
|
"message": "with Google",
|
||||||
"description": "with Google"
|
"description": "with Google"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectGoogleText": {
|
"resurrectGoogleText": {
|
||||||
"message": "with Google (text only)",
|
"message": "with Google (text only)",
|
||||||
"description": "with Google (text only)"
|
"description": "with Google (text only)"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectArchive": {
|
"resurrectArchive": {
|
||||||
"message": "with The Internet Archive",
|
"message": "with The Internet Archive",
|
||||||
"description": "with The Internet Archive"
|
"description": "with The Internet Archive"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectArchiveIs": {
|
"resurrectArchiveIs": {
|
||||||
"message": "with archive.is",
|
"message": "with archive.is",
|
||||||
"description": "with archive.is"
|
"description": "with archive.is"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectWebcitation": {
|
"resurrectWebcitation": {
|
||||||
"message": "with WebCite",
|
"message": "with WebCite",
|
||||||
"description": "with WebCite"
|
"description": "with WebCite"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectConfigCurrentTab": {
|
"resurrectConfigCurrentTab": {
|
||||||
"message": "in the current tab",
|
"message": "in the current tab",
|
||||||
"description": "in the current tab"
|
"description": "in the current tab"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectConfigNewTab": {
|
"resurrectConfigNewTab": {
|
||||||
"message": "in a new tab (foreground)",
|
"message": "in a new tab (foreground)",
|
||||||
"description": "in a new tab (foreground)"
|
"description": "in a new tab (foreground)"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectConfigNewBackgroundTab": {
|
"resurrectConfigBgTab": {
|
||||||
"message": "in a new tab (background)",
|
"message": "in a new tab (background)",
|
||||||
"description": "in a new tab (background)"
|
"description": "in a new tab (background)"
|
||||||
},
|
},
|
||||||
|
|
||||||
"contextMenuItemResurrectConfigNewWindow": {
|
"resurrectConfigNewWindow": {
|
||||||
"message": "in a new window",
|
"message": "in a new window",
|
||||||
"description": "in a new window"
|
"description": "in a new window"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
410
background.js
410
background.js
|
@ -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) {
|
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) {
|
function addResurrectItem(context, i18n, id, icon) {
|
||||||
case "resurrect-page-google": goToURL (genGoogleURL(info.pageUrl), openIn); break;
|
chrome.contextMenus.create({
|
||||||
case "resurrect-link-google": goToURL (genGoogleURL(info.linkUrl), openIn); break;
|
id: 'resurrect-' + id + '-' + context,
|
||||||
case "resurrect-slct-google": goToURL (genGoogleURL(info.selectionText), openIn); break;
|
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;
|
function addConfigItem(context, i18n, where, checked) {
|
||||||
case "resurrect-link-googletext": goToURL (genGoogleTextURL(info.linkUrl), openIn); break;
|
chrome.contextMenus.create({
|
||||||
case "resurrect-slct-googletext": goToURL (genGoogleTextURL(info.selectionText), openIn); break;
|
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;
|
['page', 'link'].forEach(context => {
|
||||||
case "resurrect-link-archive": goToURL (genIAURL(info.linkUrl), openIn); break;
|
chrome.contextMenus.create({
|
||||||
case "resurrect-slct-archive": goToURL (genIAURL(info.selectionText), openIn); break;
|
id: 'resurrect-' + context,
|
||||||
|
title: chrome.i18n.getMessage('resurrect_' + context),
|
||||||
|
contexts: [context]
|
||||||
|
}, onCreated);
|
||||||
|
|
||||||
case "resurrect-page-archiveis": goToURL (genArchiveIsURL(info.pageUrl), openIn); break;
|
addResurrectItem(context, 'Google', 'google', 'google');
|
||||||
case "resurrect-link-archiveis": goToURL (genArchiveIsURL(info.linkUrl), openIn); break;
|
addResurrectItem(context, 'GoogleText', 'google-text', 'google');
|
||||||
case "resurrect-slct-archiveis": goToURL (genArchiveIsURL(info.selectionText), openIn); break;
|
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;
|
chrome.contextMenus.create({
|
||||||
case "resurrect-link-webcitation": goToURL (genWebCiteURL(info.linkUrl), openIn); break;
|
id: 'resurrect-separator-config-' + context,
|
||||||
case "resurrect-slct-webcitation": goToURL (genWebCiteURL(info.selectionText), openIn); break;
|
type: 'separator',
|
||||||
|
contexts: [context],
|
||||||
|
parentId: 'resurrect-' + context
|
||||||
|
}, onCreated);
|
||||||
|
|
||||||
case "resurrect-page-current-tab":
|
addConfigItem(
|
||||||
case "resurrect-link-current-tab":
|
context, 'CurrentTab', 'current-tab', openIn == openInEnum.CURRENT_TAB);
|
||||||
case "resurrect-slct-current-tab":
|
addConfigItem(
|
||||||
setOpenIn (openInEnum.CURRENT_TAB);
|
context, 'NewTab', 'new-tab', openIn == openInEnum.NEW_TAB);
|
||||||
return;
|
addConfigItem(
|
||||||
case "resurrect-page-new-tab":
|
context, 'BgTab', 'bg-tab', openIn == openInEnum.BG_TAB);
|
||||||
case "resurrect-link-new-tab":
|
addConfigItem(
|
||||||
case "resurrect-slct-new-tab":
|
context, 'NewWindow', 'new-window', openIn == openInEnum.NEW_WINDOW);
|
||||||
setOpenIn (openInEnum.NEW_TAB);
|
});
|
||||||
return;
|
});
|
||||||
case "resurrect-page-new-background-tab":
|
|
||||||
case "resurrect-link-new-background-tab":
|
|
||||||
case "resurrect-slct-new-background-tab":
|
chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
||||||
setOpenIn (openInEnum.NEW_BGTAB);
|
let id = info.menuItemId;
|
||||||
return;
|
let url = null;
|
||||||
case "resurrect-page-new-window":
|
if (id.endsWith('-page')) {
|
||||||
case "resurrect-link-new-window":
|
url = info.pageUrl;
|
||||||
case "resurrect-slct-new-window":
|
} else if (id.endsWith('-link')) {
|
||||||
setOpenIn (openInEnum.NEW_WINDOW);
|
url = info.linkUrl;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
92
common.js
92
common.js
|
@ -4,71 +4,83 @@ openInEnum = {
|
||||||
NEW_BGTAB : 2,
|
NEW_BGTAB : 2,
|
||||||
NEW_WINDOW : 3
|
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) {
|
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);
|
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) {
|
||||||
var 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 genArchiveIsURL (url) {
|
function genArchiveIsUrl(url) {
|
||||||
return 'https://archive.is/'+url;
|
return 'https://archive.is/'+url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function genWebCiteURL (url) {
|
function genWebCiteUrl(url) {
|
||||||
return 'http://webcitation.org/query.php?url='+encodeURIComponent(url);
|
return 'http://webcitation.org/query.php?url='+encodeURIComponent(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOpenIn (where) {
|
|
||||||
|
function setOpenIn(where) {
|
||||||
openIn = where;
|
openIn = where;
|
||||||
browser.storage.local.set({openIn: openIn}).then(null, onError);
|
chrome.storage.local.set({openIn: openIn}, onError);
|
||||||
update_context_radios();
|
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});
|
function updateContextRadios() {
|
||||||
browser.contextMenus.update ("resurrect-link-new-tab" , {checked: openIn==openInEnum.NEW_TAB});
|
['page', 'link'].forEach(context => {
|
||||||
browser.contextMenus.update ("resurrect-link-new-background-tab", {checked: openIn==openInEnum.NEW_BGTAB});
|
chrome.contextMenus.update(
|
||||||
browser.contextMenus.update ("resurrect-link-new-window" , {checked: openIn==openInEnum.NEW_WINDOW});
|
'resurrect-current-tab-' + context,
|
||||||
|
{checked: openIn == openInEnum.CURRENT_TAB});
|
||||||
browser.contextMenus.update ("resurrect-slct-current-tab" , {checked: openIn==openInEnum.CURRENT_TAB});
|
chrome.contextMenus.update(
|
||||||
browser.contextMenus.update ("resurrect-slct-new-tab" , {checked: openIn==openInEnum.NEW_TAB});
|
'resurrect-new-tab-' + context,
|
||||||
browser.contextMenus.update ("resurrect-slct-new-background-tab", {checked: openIn==openInEnum.NEW_BGTAB});
|
{checked: openIn == openInEnum.NEW_TAB});
|
||||||
browser.contextMenus.update ("resurrect-slct-new-window" , {checked: openIn==openInEnum.NEW_WINDOW});
|
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)) {
|
function goToUrl(url, where) {
|
||||||
case openInEnum.CURRENT_TAB:
|
switch(Number(where)) {
|
||||||
browser.tabs.update({ "url": url});
|
case openInEnum.CURRENT_TAB:
|
||||||
break;
|
chrome.tabs.update({'url': url});
|
||||||
case openInEnum.NEW_TAB:
|
break;
|
||||||
browser.tabs.create({ "url": url});
|
case openInEnum.NEW_TAB:
|
||||||
break;
|
chrome.tabs.create({'url': url});
|
||||||
case openInEnum.NEW_BGTAB:
|
break;
|
||||||
browser.tabs.create({ "url": url, "active":false});
|
case openInEnum.NEW_BGTAB:
|
||||||
break;
|
chrome.tabs.create({'url': url, 'active': false});
|
||||||
case openInEnum.NEW_WINDOW:
|
break;
|
||||||
browser.windows.create({ "url": url});
|
case openInEnum.NEW_WINDOW:
|
||||||
break;
|
chrome.windows.create({'url': url});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDescription__",
|
"description": "__MSG_extensionDescription__",
|
||||||
"version": "4.1",
|
"version": "4",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
|
|
||||||
"applications": {
|
"applications": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id":"resurrect-pages@gir.st",
|
"id": "{0c8fbd76-bdeb-4c52-9b24-d587ce7b9dc3}",
|
||||||
"strict_min_version": "56.0b3"
|
"strict_min_version": "56.0b3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["common.js","background.js"]
|
"scripts": [
|
||||||
|
"common.js",
|
||||||
|
"background.js"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
|
@ -21,12 +24,18 @@
|
||||||
"default_title": "__MSG_extensionName__",
|
"default_title": "__MSG_extensionName__",
|
||||||
"default_popup": "popup.htm"
|
"default_popup": "popup.htm"
|
||||||
},
|
},
|
||||||
|
|
||||||
"commands": {
|
"commands": {
|
||||||
"_execute_browser_action": {
|
"_execute_browser_action": {
|
||||||
"suggested_key": {
|
"suggested_key": {
|
||||||
"default": "Ctrl+Shift+U"
|
"default": "Ctrl+Shift+U"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"icons": {
|
||||||
|
"16": "icons/page-16.png",
|
||||||
|
"32": "icons/page-32.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
@ -34,11 +43,5 @@
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
"tabs",
|
"tabs",
|
||||||
"activeTab"
|
"activeTab"
|
||||||
],
|
]
|
||||||
|
|
||||||
"icons": {
|
|
||||||
"16": "icons/page-16.png",
|
|
||||||
"32": "icons/page-32.png"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
57
popup.htm
57
popup.htm
|
@ -2,28 +2,55 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: sans-serif;
|
font-family: caption, sans-serif;
|
||||||
font-size: small;
|
}
|
||||||
|
button, label {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
width: 100%;
|
margin: 2px 0;
|
||||||
text-align:left;
|
padding: 2px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
font-size: small;
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
vertical-align:bottom;
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<form>
|
<form>
|
||||||
<button id="resurrectWithGoogle" ><img src="icons/cacheicons/google.png"> <span id="lgo"></span></button><br>
|
<button data-locale="resurrectGoogle" data-gen="genGoogleUrl">
|
||||||
<button id="resurrectWithGoogleText" ><img src="icons/cacheicons/google.png"> <span id="lgt"></span></button><br>
|
<img src="icons/cacheicons/google.png">
|
||||||
<button id="resurrectWithInternetArchive"><img src="icons/cacheicons/waybackmachine.png"> <span id="lia"></span></button><br>
|
</button>
|
||||||
<button id="resurrectWithArchiveIs" ><img src="icons/cacheicons/archiveis.png"> <span id="lai"></span></button><br>
|
<button data-locale="resurrectGoogleText" data-gen="genGoogleTextUrl">
|
||||||
<button id="resurrectWithWebCite" ><img src="icons/cacheicons/webcitation.png"> <span id="lwc"></span></button><br>
|
<img src="icons/cacheicons/google.png">
|
||||||
<hr>
|
</button>
|
||||||
<input type="radio" name="openIn" value="0" id="current" ><label for="current" id="lc"></label></br>
|
<button data-locale="resurrectArchive" data-gen="genIaUrl">
|
||||||
<input type="radio" name="openIn" value="1" id="newtabfg"><label for="newtabfg" id="ltf"></label></br>
|
<img src="icons/cacheicons/waybackmachine.png">
|
||||||
<input type="radio" name="openIn" value="2" id="newtabbg"><label for="newtabbg" id="ltb"></label></br>
|
</button>
|
||||||
<input type="radio" name="openIn" value="3" id="newwin" ><label for="newwin" id="lw"></label></br>
|
<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>
|
</form>
|
||||||
|
|
||||||
<script src="common.js"></script>
|
<script src="common.js"></script>
|
||||||
|
|
74
popup.js
74
popup.js
|
@ -1,46 +1,32 @@
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
chrome.storage.local.get('openIn', res => {
|
||||||
browser.storage.local.get ("openIn").then(function(res) {
|
document.querySelectorAll('input[type=radio]').forEach(el => {
|
||||||
switch (Number(res.openIn)) {
|
el.checked = el.value == 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");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
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.querySelectorAll('*[data-locale]').forEach(el => {
|
||||||
document.querySelector("#lw").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectConfigNewWindow");
|
el.innerHTML += ' ' + chrome.i18n.getMessage(el.getAttribute('data-locale'));
|
||||||
|
});
|
||||||
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)};
|
function onOpenInChange() {
|
||||||
document.querySelector("#newwin").onchange = function(){setOpenIn(document.querySelector('input[name="openIn"]:checked').value)};
|
setOpenIn(document.querySelector('input[name="openIn"]:checked').value);
|
||||||
|
};
|
||||||
document.querySelector("#lgo").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectGoogle");
|
document.querySelectorAll('input[type=radio]').forEach(el => {
|
||||||
document.querySelector("#lgt").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectGoogleText");
|
el.addEventListener('click', onOpenInChange, true);
|
||||||
document.querySelector("#lia").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectArchive");
|
});
|
||||||
document.querySelector("#lai").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectArchiveIs");
|
|
||||||
document.querySelector("#lwc").innerHTML = browser.i18n.getMessage("contextMenuItemResurrectWebcitation");
|
|
||||||
|
function resurrect(gen) {
|
||||||
browser.tabs.query({active:true,currentWindow:true}).then(function(tabObj){
|
return function() {
|
||||||
pageURL = tabObj[0].url;
|
chrome.tabs.query({active: true, currentWindow: true}, tabObj => {
|
||||||
document.querySelector("#resurrectWithGoogle").onclick = function(){goToURL (genGoogleURL (pageURL), openIn);window.close()};
|
goToUrl(gen(tabObj[0].url), openIn);
|
||||||
document.querySelector("#resurrectWithGoogleText").onclick = function(){goToURL (genGoogleTextURL(pageURL), openIn);window.close()};
|
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('button').forEach(el => {
|
||||||
|
el.addEventListener(
|
||||||
|
'click', resurrect(window[el.getAttribute('data-gen')]), true);
|
||||||
});
|
});
|
||||||
|
|
Chargement…
Référencer dans un nouveau ticket