Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,36 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) {
let id = info.menuItemId;
let url = null;
if (id.endsWith('-page')) {
url = info.pageUrl;
url = processPageUrlEdgeCases(info.pageUrl);
} else if (id.endsWith('-link')) {
url = info.linkUrl;
}

if (id.startsWith('resurrect-google-')) {
goToUrl(genGoogleUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-googletext-')) {
goToUrl(genGoogleTextUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archive-')) {
goToUrl(genIaUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archivelist-')) {
goToUrl(genIaListUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archiveis-')) {
goToUrl(genArchiveIsUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-webcitation-')) {
goToUrl(genWebCiteUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-mementoweb-')) {
goToUrl(genMementoUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-current-tab-')) {
if (url != null) {
if (id.startsWith('resurrect-google-')) {
goToUrl(genGoogleUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-googletext-')) {
goToUrl(genGoogleTextUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archive-')) {
goToUrl(genIaUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archivelist-')) {
goToUrl(genIaListUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archiveis-')) {
goToUrl(genArchiveIsUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-webcitation-')) {
goToUrl(genWebCiteUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-mementoweb-')) {
goToUrl(genMementoUrl(url), openIn, tab.id);
}
}

if (id.startsWith('resurrect-current-tab-')) {
setOpenIn(openInEnum.CURRENT_TAB);
} else if (id.startsWith('resurrect-new-tab-')) {
setOpenIn(openInEnum.NEW_TAB);
setOpenIn(openInEnum.NEW_TAB);
} else if (id.startsWith('resurrect-bg-tab-')) {
setOpenIn(openInEnum.NEW_BGTAB);
setOpenIn(openInEnum.NEW_BGTAB);
} else if (id.startsWith('resurrect-new-window-')) {
setOpenIn(openInEnum.NEW_WINDOW);
setOpenIn(openInEnum.NEW_WINDOW);
}
});
14 changes: 14 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ function genMementoUrl(url) {
}


/* process edge cases in the page URL
* file:// scheme pages and FF reader mode
*/
function processPageUrlEdgeCases(url) {
if (url.startsWith('about:reader?url=')) {
return decodeURIComponent(url.replace('about:reader?url=', ''));
}
else if (url.startsWith('file:') || url.startsWith('about:')) {
return null
}
return url;
}


function setOpenIn(where) {
openIn = where;
chrome.storage.local.set({openIn: openIn}, logLastError);
Expand Down
13 changes: 10 additions & 3 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ function resurrect(gen) {
return function() {
chrome.tabs.query({active: true, currentWindow: true}, tabObj => {
logLastError();
let url = gen(tabObj[0].url);
console.info('Resurrecting via URL', url);
goToUrl(url, openIn, tabObj[0].id);

var url = processPageUrlEdgeCases(tabObj[0].url);

if (url != null)
{
let archiveUrl = gen(url);
console.info('Resurrecting via URL', archiveUrl);
goToUrl(archiveUrl, openIn, tabObj[0].id);
}

window.close();
});
}
Expand Down