Browse Source

Specify openerTabId for opened tabs

See https://github.com/arantius/resurrect-pages/pull/44
master
Albirew 2 years ago
parent
commit
ca7773baf7
  1. 16
      background.js
  2. 8
      common.js
  3. 2
      manifest.json
  4. 2
      popup.js

16
background.js

@ -63,21 +63,21 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) {
url = info.linkUrl;
}
if (id.startsWith('resurrect-google-')) {
goToUrl(genGoogleUrl(url), openIn);
goToUrl(genGoogleUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-googletext-')) {
goToUrl(genGoogleTextUrl(url), openIn);
goToUrl(genGoogleTextUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archive-')) {
goToUrl(genIaUrl(url), openIn);
goToUrl(genIaUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archivelist-')) {
goToUrl(genIaListUrl(url), openIn);
goToUrl(genIaListUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-archiveis-')) {
goToUrl(genArchiveIsUrl(url), openIn);
goToUrl(genArchiveIsUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-isup-')) {
goToUrl(genIsUpUrl(url), openIn);
goToUrl(genIsUpUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-webcitation-')) {
goToUrl(genWebCiteUrl(url), openIn);
goToUrl(genWebCiteUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-mementoweb-')) {
goToUrl(genMementoUrl(url), openIn);
goToUrl(genMementoUrl(url), openIn, tab.id);
} else if (id.startsWith('resurrect-current-tab-')) {
setOpenIn(openInEnum.CURRENT_TAB);
} else if (id.startsWith('resurrect-new-tab-')) {

8
common.js

@ -37,7 +37,7 @@ function genIaListUrl(url) {
}
function genArchiveIsUrl(url) {
return 'https://archive.md/'+url;
return 'https://archive.ph/'+url;
}
function genWebCiteUrl(url) {
@ -77,16 +77,16 @@ function updateContextRadios() {
});
}
function goToUrl(url, where) {
function goToUrl(url, where, openerTabId) {
switch(Number(where)) {
case openInEnum.CURRENT_TAB:
chrome.tabs.update({'url': url});
break;
case openInEnum.NEW_TAB:
chrome.tabs.create({'url': url});
chrome.tabs.create({'url': url, openerTabId});
break;
case openInEnum.NEW_BGTAB:
chrome.tabs.create({'url': url, 'active': false});
chrome.tabs.create({'url': url, 'active': false, openerTabId});
break;
case openInEnum.NEW_WINDOW:
chrome.windows.create({'url': url});

2
manifest.json

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

2
popup.js

@ -23,7 +23,7 @@ function resurrect(gen) {
logLastError();
let url = gen(tabObj[0].url);
console.info('Resurrecting via URL', url);
goToUrl(url, openIn);
goToUrl(url, openIn, tabObj[0].id);
window.close();
});
}

Loading…
Cancel
Save