diff --git a/manifest.json b/manifest.json index 70d0cc64e2bdcd4bf80f73712563bde871b5275f..000b24f039e9e5e3ce80787919bad341ec8bf67c 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ }, "permissions": [ - "activeTab","storage","webRequest", "webRequestBlocking", "<all_urls>" + "activeTab","storage","webRequest", "webRequestBlocking", "<all_urls>" ,"tabs" ], "background": { diff --git a/popup/menu.js b/popup/menu.js index b90cdc7c8e0d6956731f3c18683ebe90d55b5cb4..8af4f76a5ea6dcd46e985df3270c0753953b4fd7 100644 --- a/popup/menu.js +++ b/popup/menu.js @@ -41,7 +41,24 @@ function start_modify() function start_config() { - //var strWindowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=800,height=600"; - // window.open("config.html","Simple Modify Headers",strWindowFeatures); - browser.tabs.create({url:"config.html"}); + var promise_tabs = browser.tabs.query({currentWindow: true}); + promise_tabs.then(loadConfigTab); + } + + +function loadConfigTab(tabs) + { + var config_tab; + + // search for config tab + for (let tab of tabs) + { + if (tab.url.startsWith(browser.extension.getURL(""))) config_tab = tab; + } + + // config tab exits , put the focus on it + if (config_tab) browser.tabs.update(config_tab.id,{active:true}) + + // else create a new tab + else browser.tabs.create({url:"config.html"}); }