duplicate-tab icon indicating copy to clipboard operation
duplicate-tab copied to clipboard

Open link as duplicate

Open nmatt opened this issue 3 years ago • 3 comments

One useful benefit when duplicating a tab is that the tab's history is also duplicated (i.e. "back" still works in the clone). In Internet Explorer, opening a link in a new tab/window (e.g. Shift/Ctrl+Click) also clones the history, whereas in Chrome and Firefox the history unfortunately is reset in the new tab/window and not copied. I'm wondering whether the Extension API would allow adding that feature. I imagine it could be emulated by first duplicating the tab and then opening the link in the new cloned tab, thus retaining the history. Ideally Shift/Ctrl+Click could be mapped to the new behavior.

I'm aware that this is outside the original scope of the duplicate-tab extension, but maybe you'd find that feature interesting? Looking forward to any feedback you can give.

nmatt avatar Jul 12 '21 11:07 nmatt

It would probably be possible with something like the following:


chrome.contextMenus.onClicked.addListener(function(info, tab) {
  if (info.menuItemId == "duplicate-link") {
    chrome.tabs.duplicate(tab.id, function(newTab) {
      chrome.tabs.update(newTab.id, {
        url: info.linkUrl,
      });
    });
  }
})

chrome.contextMenus.create({
  id: "duplicate-link",
  title: "Duplicate Link",
  contexts: ["link"],
});

You also have to add "contextMenus" to the "permissions" in manifest.json.

I haven't actually tried this though.. but the above should hopefully get you started. I'm not sure if I'd want to include this in the extension since I don't think very many people would use it. But who knows, if a lot of people post in this issue that they want it then maybe I could change my mind.

I have another extension of mine that adds context menus, so you may be able to get inspiration from it too. https://github.com/stefansundin/open-with-vlc

Good luck!

stefansundin avatar Jul 12 '21 18:07 stefansundin

@stefansundin: Thanks for looking into it! I haven't looked into development of extensions myself yet, but this gives me incentive to take a shot at it.

nmatt avatar Jul 12 '21 20:07 nmatt

@stefansundin @nmatt @Sleavely but in brave browser/chromium even if we open the same link in other tab manually it doesn't record this event in the history.

yash10019coder avatar Jul 19 '22 20:07 yash10019coder