From b975f183fe19250c67b2c8617c2a76f9cdf71548 Mon Sep 17 00:00:00 2001 From: NateN1222 Date: Sat, 9 Sep 2017 14:10:26 -0500 Subject: Implemented buttons in context menu, improved options screen, added window to the list of nontrivial objects --- html/display_panel/content/main_panel.js | 11 ++++++----- html/preferences_panel/pref.js | 24 ++++++++++++++++++++++-- html/preferences_panel/preferences_panel.html | 6 +++++- 3 files changed, 33 insertions(+), 8 deletions(-) (limited to 'html') diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 9752e10..fddc3a6 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -70,7 +70,7 @@ function write_elements(data,name,color){ } else{ heading.innerHTML = "

List of
" + name.toUpperCase() + "
javascript in " + data["url"]+":

"; } - // Iterate over data[name] and generate bulleted list + // Iterate over data[name] and generate list for(var i = 0; i < data[name].length; i++){ list.innerHTML += "
  • "+data[name][i][0]+ ":
    " + data[name][i][1]+"\n"+button_html+"

    \n"+button_html_2+"

    \n"+button_html_3+"
  • "; document.getElementById("temp").id = name+"_"+i; @@ -154,9 +154,9 @@ function generate_HTML(blocked_data){ // This should send a message to invoke the content finder var button_complain = 'Complain to site owner'; // This should update the persistent options - var button_allow_all = 'Allow all scripts in this page'; + var button_allow_all = ''+"Add page's domain to whitelist"+''; // This will call "Forget preferences" on every script. - var button_block_nonfree = 'Block all nonfree/nontrivial scripts from this page'; + var button_block_nonfree = ''+"Remove page's domain from whitelist"+''; // This should send a message that calls "open_popup_tab()" in the background script var button_new_tab = 'Open this report in a new tab'; @@ -175,10 +175,11 @@ function generate_HTML(blocked_data){ if( blocked_data["blacklisted"].length != 0 || blocked_data["blocked"].length != 0 || blocked_data["whitelisted"].length != 0 || blocked_data["accepted"].length != 0){ write_button(button_allow_all,function(){ - console.log("button_allow_all"); + myPort.postMessage({"allow_all": blocked_data}); }); write_button(button_block_nonfree,function(){ - console.log("button_block_nonfree"); + myPort.postMessage({"block_all": blocked_data}); + }); write_button(button_complain,function(){ myPort.postMessage({"invoke_contact_finder": blocked_data}); diff --git a/html/preferences_panel/pref.js b/html/preferences_panel/pref.js index aa88f5d..223165f 100644 --- a/html/preferences_panel/pref.js +++ b/html/preferences_panel/pref.js @@ -20,16 +20,31 @@ set_webex(); function storage_got(items){ var inputs = document.getElementsByTagName("input"); + + if(items["pref_whitelist"] == "undefined"){ + items["pref_whitelist"] = ""; + } + + if(items["pref_subject"] == "undefined" || items["pref_subject"] == ""){ + items["pref_subject"] = "Issues with Javascript on your website"; + } + + if(items["pref_body"] == "undefined" || items["pref_body"] == ""){ + items["pref_body"] = "Please consider using a free license for the Javascript on your website. [Message generated by LibreJS. See https://www.gnu.org/software/librejs/ for more information]"; + } + for(var i = 0; i < inputs.length; i++){ if(inputs[i].id.indexOf("pref_") != -1){ if(inputs[i].type == "checkbox" && items[inputs[i].id]){ inputs[i].checked = true; } - if(inputs[i].type == "text"){ + if(inputs[i].type == "text" && items[inputs[i].id] != undefined){ inputs[i].value = items[inputs[i].id]; } } } + + } webex.storage.local.get(storage_got); @@ -43,13 +58,18 @@ document.getElementById("save_changes").addEventListener("click", function(){ if(inputs[i].type == "checkbox"){ input_val = inputs[i].checked; } else{ - input_val = inputs[i].value; + if(inputs[i.value] != "undefined"){ + input_val = inputs[i].value; + } else{ + input_val = ""; + } } var input_id = inputs[i].id; data[input_id] = input_val; } } console.log(data); + webex.storage.local.set(data); }); diff --git a/html/preferences_panel/preferences_panel.html b/html/preferences_panel/preferences_panel.html index 5c5a217..2d01f94 100644 --- a/html/preferences_panel/preferences_panel.html +++ b/html/preferences_panel/preferences_panel.html @@ -34,9 +34,11 @@ - + + -- cgit v1.2.3

    Whitelist domains, seperated by comma (wildcard is *)

    Allow all scripts from pages with this text
    in their URL. (Comma seperated, wildcard is *)

    Default complaint email subject