Skip to content
Permalink
Browse files

Only match localhost tabs

  • Loading branch information...
Samir L. Boulema
Samir L. Boulema committed Sep 25, 2015
1 parent 74193f2 commit b1d1eef3936ed3e291966e83e14613858ea20495
Showing with 8 additions and 5 deletions.
  1. +4 −4 README.md
  2. +4 −1 reusetab.js
@@ -1,10 +1,10 @@
# Reuse Tab Chrome Extension #
# Reuse Localhost Tab Chrome Extension #

## Why? #

Pinned tabs in Chrome are great. However, opening external links causes a new
tab to be opened, even if the host of the new URL matches that in your pinned
tab. This extension addresses that problem.
Opening external links causes a new tab to be opened,
even if the host of the new URL matches that in your existing
tabs. This extension addresses that problem.

## Changelog ##

@@ -8,11 +8,14 @@ function onUriKnown(newTab) {
if (newTab.pinned) return;
var url = newTab.url;
var host = parseUri(url).host;
chrome.tabs.query({"pinned": true}, function(pinnedTabs) {
if (host !== "localhost") return;
chrome.tabs.query({"pinned": false}, function(pinnedTabs) {
var matchedTab = _.find(pinnedTabs, function(pinnedTab) {
return parseUri(pinnedTab.url).host === host;
});
log(matchedTab);
if (!matchedTab) return;
if (matchedTab.id === newTab.id) return;
chrome.tabs.update(matchedTab.id, {"url": url, "active": true});
chrome.tabs.remove(newTab.id);
// make sure the new window is focused. on my version of chrome,

0 comments on commit b1d1eef

Please sign in to comment.
You can’t perform that action at this time.