Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open link as duplicate #14

Open
nmatt opened this issue Jul 12, 2021 · 3 comments
Open

Open link as duplicate #14

nmatt opened this issue Jul 12, 2021 · 3 comments

Comments

@nmatt
Copy link

nmatt commented Jul 12, 2021

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.

@stefansundin
Copy link
Owner

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!

@nmatt
Copy link
Author

nmatt commented Jul 12, 2021

@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.

@yash10019coder
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants