diff options
author | Einar Egilsson <einar@einaregilsson.com> | 2016-05-31 14:53:32 +0200 |
---|---|---|
committer | Einar Egilsson <einar@einaregilsson.com> | 2016-05-31 14:53:32 +0200 |
commit | 44dfb4ec3c4585454ebfbb7b30fe7774c5c6a877 (patch) | |
tree | f37394844b1b1960d77e6dd1ac6275d23415cc6e /js/popup.js | |
parent | 77f60e0af6c36009a9bb6edbea04aeace9478637 (diff) |
Mostly Firefox compatible
Diffstat (limited to 'js/popup.js')
-rw-r--r-- | js/popup.js | 13 |
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) { |