aboutsummaryrefslogtreecommitdiff
path: root/main_background.js
diff options
context:
space:
mode:
authorNateN1222 <nathannichols454@gmail.com>2018-01-27 10:54:08 -0600
committerNateN1222 <nathannichols454@gmail.com>2018-01-27 10:54:08 -0600
commit4089cd1dcd7c303e709331c299521266a0b2bdd7 (patch)
tree05ee57b0c93bd39005148a0104477905ecbc4b06 /main_background.js
parent09f4708f61c29d24bf46505d04cf223a1e0325d7 (diff)
Added pre-request blocking for Google Analytics so that Google cannot register
that the script was even requested.
Diffstat (limited to 'main_background.js')
-rw-r--r--main_background.js43
1 files changed, 39 insertions, 4 deletions
diff --git a/main_background.js b/main_background.js
index 4d60869..bf7feff 100644
--- a/main_background.js
+++ b/main_background.js
@@ -32,9 +32,10 @@ console.log("main_background.js");
*
*/
var DEBUG = false;
+var PRINT_DEBUG = true
function dbg_print(a,b){
- if(DEBUG == true){
+ if(PRINT_DEBUG == true){
if(b === undefined){
console.log(a);
} else{
@@ -1652,10 +1653,12 @@ function full_evaluate(script){
}
}
var error_count = 0;
- while(toke.type != acorn_base.tokTypes.eof){
+ while(toke !== undefined && toke.type != acorn_base.tokTypes.eof){
if(toke.type.keyword !== undefined){
+ //dbg_print("Keyword:");
+ //dbg_print(toke);
+
// This type of loop detection ignores functional loop alternatives and ternary operators
- //dbg_print("Keyword:"+toke.type.keyword);
if(toke.type.keyword == "function"){
dbg_print("%c NONTRIVIAL: Function declaration.","color:red");
@@ -1963,7 +1966,25 @@ function get_script(response,url,tabid,wl,index=-1){
});
});
}
-
+function block_ga(a){
+ console.log(a.url);
+ // This is actually just an HTML page
+ if(a.url == 'https://www.google.com/analytics/#?modal_active=none'){
+ return;
+ }
+ 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'){
+ dbg_print("%c Google analytics (2)","color:red");
+ return {cancel: true};
+ }
+ if(a.url == 'https://www.google.com/analytics/js/analytics.min.js'){
+ dbg_print("%c Google analytics (3)","color:red");
+ return {cancel: true};
+ }
+}
function read_script(a){
var filter = webex.webRequest.filterResponseData(a.requestId);
@@ -2141,6 +2162,20 @@ function init_addon(){
webex.storage.onChanged.addListener(options_listener);
webex.tabs.onRemoved.addListener(delete_removed_tab_info);
+ // Prevents Google Analytics from being loaded from Google servers
+ var all_types = [
+ "beacon", "csp_report", "font", "image", "imageset", "main_frame", "media",
+ "object", "object_subrequest", "ping", "script", "stylesheet", "sub_frame",
+ "web_manifest", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt",
+ "other"
+ ]
+ // Analyzes remote scripts
+ webex.webRequest.onBeforeRequest.addListener(
+ block_ga,
+ {urls:["<all_urls>"], types:all_types},
+ ["blocking"]
+ );
+
// Analyzes remote scripts
webex.webRequest.onBeforeRequest.addListener(
read_script,