From ec120cf896aee2c595d957745f9909a506c8036c Mon Sep 17 00:00:00 2001 From: NateN1222 Date: Thu, 10 Aug 2017 15:27:48 -0500 Subject: Started to implement the buttons in the pop-up and the "open in new tab" option --- main_background.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'main_background.js') diff --git a/main_background.js b/main_background.js index 75a5917..0d8fb13 100644 --- a/main_background.js +++ b/main_background.js @@ -48,9 +48,15 @@ function options_listener(changes, area){ * by opening a new tab with whatever HTML is in the popup * at the moment. */ -function open_popup_tab(){ +var active_connections = {}; +var unused_data = {}; +function open_popup_tab(data){ + console.log(data); function gotPopup(popupURL){ - var creating = webex.tabs.create({"url":popupURL}); + var creating = webex.tabs.create({"url":popupURL},function(a){ + console.log("[TABID:"+a["id"]+"] creating unused data entry from parent window's content"); + unused_data[a["id"]] = data; + }); } var gettingPopup = webex.browserAction.getPopup({},gotPopup); @@ -95,8 +101,6 @@ function debug_print_local(){ * } * */ -var active_connections = {}; -var unused_data = {}; function update_popup(tab_id,blocked_info_arg,update=false){ var new_blocked_data; @@ -238,6 +242,10 @@ function connected(p) { set_script(m["forget"][0],"forget"); update = true; } + // + if(m["open_popup_tab"] !== undefined){ + open_popup_tab(m["open_popup_tab"]); + } // a debug feature if(m["printlocalstorage"] !== undefined){ debug_print_local(); @@ -249,10 +257,16 @@ function connected(p) { function logTabs(tabs) { if(update){ - console.log("%c updating tab "+tabs[0]["id"],"color: red;"); - update_popup(tabs[0]["id"],unused_data[tabs[0]["id"]],true); - active_connections[tabs[0]["id"]] = p; - return; + + // TODO: check the Firefox equivalent reserved URL pattern + if(typeof(tabs[0]["url"].match(/chrome\-extension:\/\/.*display-panel\.html/g)) == "object"){ + console.log("%c Not updating popup because this is a reserved page","color: red;"); + return; + } else{ + console.log("%c updating tab "+tabs[0]["id"],"color: red;"); + update_popup(tabs[0]["id"],unused_data[tabs[0]["id"]],true); + active_connections[tabs[0]["id"]] = p; + } } for(var i = 0; i < tabs.length; i++) { var tab = tabs[i]; -- cgit v1.2.3