aboutsummaryrefslogtreecommitdiff
path: root/main_background.js
diff options
context:
space:
mode:
authorNateN1222 <nathannichols454@gmail.com>2018-03-03 20:43:37 -0600
committerNateN1222 <nathannichols454@gmail.com>2018-03-03 20:43:37 -0600
commit3f0d71e0fabc04e346a5b8ea4a3f730bb7f0c9f6 (patch)
tree018a60fdc18c482833a96737623fa4b5f0f32086 /main_background.js
parenta656240e082653865dc40e072b01f15628d0a5e6 (diff)
parentdae60954ec85b7939431b584b06e8f121f91ae6b (diff)
fixed merge conflict
Diffstat (limited to 'main_background.js')
-rw-r--r--main_background.js48
1 files changed, 22 insertions, 26 deletions
diff --git a/main_background.js b/main_background.js
index 0a4327f..1a891ac 100644
--- a/main_background.js
+++ b/main_background.js
@@ -353,20 +353,20 @@ function update_popup(tab_id,blocked_info,update=false){
return "whitelist";
} else{
//console.log("script " + script_name + " not in default whitelist.");
+ return "none";
}
- return "none";
}
function is_bl(script_name){
if(get_status(script_name) == "blacklist"){
return true;
}
- return false;
+ else return false;
}
function is_wl(script_name){
if(get_status(script_name) == "whitelist"){
return true;
}
- return false;
+ else return false;
}
new_blocked_data = {
"accepted":[],
@@ -413,6 +413,7 @@ function update_popup(tab_id,blocked_info,update=false){
active_connections[tab_id].postMessage({"show_info":new_blocked_data});
delete active_connections[tab_id];
}
+ return 0;
}
webex.storage.local.get(get_sto);
}
@@ -547,6 +548,8 @@ function add_popup_entry(tab_id,src_hash,blocked_info,update=false){
}
}
webex.storage.local.get(get_sto);
+
+ return 0;
});
}
@@ -605,7 +608,6 @@ function connected(p) {
}
}
var querying = webex.tabs.query({active: true,currentWindow: true},geturl);
- return;
}
var update = false;
var contact_finder = false;
@@ -732,7 +734,6 @@ function blocked_status(hash){
}
}
resolve("none");
- return;
}
webex.storage.local.get(cb);
});
@@ -1600,6 +1601,7 @@ function full_evaluate(script){
/**
* Given the end of an identifer token, it tests for bracket suffix notation
+ * TODO: this function and the next could probably be replaced by a regex
*/
function being_called(end){
var i = 0;
@@ -1609,14 +1611,12 @@ function full_evaluate(script){
return false;
}
}
- if(script.charAt(end+i) == "("){
- return true;
- }else{
- return false;
- }
+
+ return script.charAt(end+i) == "(";
}
/**
* Given the end of an identifer token, it tests for parentheses
+ * TODO: this function and the previous could probably be replaced by a regex
*/
function is_bsn(end){
var i = 0;
@@ -1626,11 +1626,7 @@ function full_evaluate(script){
return false;
}
}
- if(script.charAt(end+i) == "["){
- return true;
- }else{
- return false;
- }
+ return script.charAt(end+i) == "[";
}
var error_count = 0;
while(toke !== undefined && toke.type != acorn_base.tokTypes.eof){
@@ -1795,7 +1791,7 @@ function license_read(script_src,name){
var nontrivial_status;
var parts_denied = false;
var parts_accepted = false;
- while(true){
+ while(true){ // TODO: refactor me
// TODO: support multiline comments
var matches = /\/\s*?(@license)\s([\S]+)\s([\S]+$)/gm.exec(unedited_src);
if(matches == null){
@@ -1815,7 +1811,7 @@ function license_read(script_src,name){
if(parts_denied == true && parts_accepted == false){
return [false,edited_src,reason_text];
}
- return [true,edited_src,reason_text];
+ else return [true,edited_src,reason_text];
}
var before = unedited_src.substr(0,matches["index"]);
@@ -1950,24 +1946,24 @@ function get_script(response,url,tabid,wl,index=-1){
/**
* Tests if a request is google analytics or not
*/
-function test_GA(a){
+function test_GA(a){ // TODO: DRY me
// This is just an HTML page
if(a.url == 'https://www.google.com/analytics/#?modal_active=none'){
return false;
}
- if(a.url.match(/https:\/\/www\.google\.com\/analytics\//g)){
+ else if(a.url.match(/https:\/\/www\.google\.com\/analytics\//g)){
dbg_print("%c Google analytics (1)","color:red");
return {cancel: true};
}
- if(a.url == 'https://www.google-analytics.com/analytics.js'){
+ else if(a.url == 'https://www.google-analytics.com/analytics.js'){
dbg_print("%c Google analytics (2)","color:red");
return {cancel: true};
}
- if(a.url == 'https://www.google.com/analytics/js/analytics.min.js'){
+ else if(a.url == 'https://www.google.com/analytics/js/analytics.min.js'){
dbg_print("%c Google analytics (3)","color:red");
return {cancel: true};
}
- return false;
+ else return false;
}
/**
@@ -1978,11 +1974,15 @@ function block_ga(a){
if(GA != false){
return GA;
}
+ else return {};
}
+<<<<<<< HEAD
/**
* This is a callback trigged from requests caused by script tags with the src="" attribute.
*/
+=======
+>>>>>>> dae60954ec85b7939431b584b06e8f121f91ae6b
function read_script(a){
var GA = test_GA(a);
if(GA !== false){
@@ -2011,7 +2011,6 @@ function read_script(a){
});
}
return {};
-
}
/**
@@ -2141,7 +2140,6 @@ function read_document(a){
// Doesn't matter if this is accepted or blocked, it will still be whitelisted
filter.write(encoder.encode(str));
filter.disconnect();
- return;
} else{
edit_page = edit_html(str,a.url,a["tabId"],false);
edit_page.then(function(edited){
@@ -2153,10 +2151,8 @@ function read_document(a){
}
filter.ondata = event => {
str += decoder.decode(event.data, {stream: true});
- return;
}
return {};
-
}
/**