aboutsummaryrefslogtreecommitdiff
path: root/js/popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/popup.js')
-rw-r--r--js/popup.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/js/popup.js b/js/popup.js
index 5305f13..1241d20 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -21,6 +21,19 @@ angular.module('popupApp', []).controller('PopupCtrl', ['$scope', function($s) {
//switch to open one if we have it to minimize conflicts
var url = chrome.extension.getURL('redirector.html');
+ chrome.tabs.query({currentWindow:true}, function(tabs)) {
+ for (var i=0; i < tabs.length; i++) {
+ if (tabs[i].url == url) {
+ chrome.tabs.update(tabs[i].id, {active:true}, function(tab) {
+ close();
+ });
+ return;
+ }
+ }
+
+ chrome.tabs.create({url:url, active:true});
+ });
+ return;
chrome.tabs.query({currentWindow:true, url:url}, function(tabs) {
if (tabs.length > 0) {
chrome.tabs.update(tabs[0].id, {active:true}, function(tab) {