aboutsummaryrefslogtreecommitdiff
path: root/main_background.js
diff options
context:
space:
mode:
authorNateN1222 <nathannichols454@gmail.com>2018-02-04 10:13:10 -0600
committerNateN1222 <nathannichols454@gmail.com>2018-02-04 10:13:10 -0600
commit976be36bc673e6a66b1e745833659a50740148b2 (patch)
tree612eeb60638596618e9b879b865e0a4a17744af5 /main_background.js
parent099ee11f774939589305ad7f85fa2a36382369eb (diff)
Made all onBeforeRequest listeners cancel requests to Google Analytics URLs
incase it doesn't cancel if only one of them cancels the request.
Diffstat (limited to 'main_background.js')
-rw-r--r--main_background.js49
1 files changed, 35 insertions, 14 deletions
diff --git a/main_background.js b/main_background.js
index 81905b2..39ac6e6 100644
--- a/main_background.js
+++ b/main_background.js
@@ -31,8 +31,8 @@ console.log("main_background.js");
* Also, it controls whether or not this part of the code logs to the console.
*
*/
-var DEBUG = false;
-var PRINT_DEBUG = true
+var DEBUG = false; // debug the JS evaluation
+var PRINT_DEBUG = false; // Everything else
function dbg_print(a,b){
if(PRINT_DEBUG == true){
@@ -89,8 +89,6 @@ var intrinsicEvents = [
WAYS TO DETERMINE PASS/FAIL:
- "// @license [magnet link] [identifier]" then "// @license-end" (may also use /* comments)
- Automatic whitelist: (http://bzr.savannah.gnu.org/lh/librejs/dev/annotate/head:/data/script_libraries/script-libraries.json_
- - <table id="jslicense-labels1"><table> which may be linked to by a link tag identified by rel="jslicense" or data-jslicense="1"
- - In the first script tag, declare the license with @licstart/@licend
*/
var licenses = {
@@ -161,12 +159,6 @@ var licenses = {
'URL': 'http://www.mozilla.org/MPL/2.0',
'Magnet link': 'magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt'
},
- // "Public domain is not a license"
- // Replace with CC0?
- 'Public-Domain':{
- 'URL': 'https://www.gnu.org/licenses/license-list.html#PublicDomain',
- 'Magnet link': 'magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt'
- },
'UPL-1.0': {
'URL': 'https://oss.oracle.com/licenses/upl/',
'Magnet link': 'magnet:?xt=urn:btih:478974f4d41c3fa84c4befba25f283527fad107d&dn=upl-1.0.txt'
@@ -431,8 +423,14 @@ function update_popup(tab_id,blocked_info,update=false){
// store the blocked info until it is opened and needed
if(update == false && active_connections[tab_id] === undefined){
dbg_print("[TABID:"+tab_id+"]"+"Storing blocked_info for when the browser action is opened or asks for it.");
+ if(tab_id == undefined){
+ dbg_print("UNDEFINED TAB_ID");
+ }
unused_data[tab_id] = new_blocked_data;
} else{
+ if(tab_id == undefined){
+ dbg_print("UNDEFINED TAB_ID");
+ }
unused_data[tab_id] = new_blocked_data;
dbg_print("[TABID:"+tab_id+"]"+"Sending blocked_info directly to browser action");
active_connections[tab_id].postMessage({"show_info":new_blocked_data});
@@ -562,6 +560,9 @@ function add_popup_entry(tab_id,src_hash,blocked_info,update=false){
//console.log("Script " + blocked_info[type][0] + " isn't whitelisted or blacklisted");
}
if(not_duplicate(type_key,blocked_info[type])){
+ dbg_print(unused_data);
+ dbg_print(unused_data[tab_id]);
+ dbg_print(type_key);
unused_data[tab_id][type_key].push(blocked_info[type]);
resolve(res);
} else{
@@ -1966,11 +1967,14 @@ function get_script(response,url,tabid,wl,index=-1){
});
});
}
-function block_ga(a){
- console.log(a.url);
+
+/**
+* Tests if a request is google analytics or not
+*/
+function test_GA(a){
// This is just an HTML page
if(a.url == 'https://www.google.com/analytics/#?modal_active=none'){
- return;
+ return false;
}
if(a.url.match(/https:\/\/www\.google\.com\/analytics\//g)){
dbg_print("%c Google analytics (1)","color:red");
@@ -1984,8 +1988,20 @@ function block_ga(a){
dbg_print("%c Google analytics (3)","color:red");
return {cancel: true};
}
+ return false;
+}
+
+function block_ga(a){
+ var GA = test_GA(a);
+ if(GA != false){
+ return GA;
+ }
}
function read_script(a){
+ var GA = test_GA(a);
+ if(GA !== false){
+ return GA;
+ }
var filter = webex.webRequest.filterResponseData(a.requestId);
var decoder = new TextDecoder("utf-8");
@@ -2110,7 +2126,12 @@ function edit_html(html,url,tabid,wl){
*
*/
function read_document(a){
-
+
+ var GA = test_GA(a);
+ if(GA != false){
+ return GA;
+ }
+
if(unused_data[a["tabId"]] !== undefined && unused_data[a["tabId"]]["url"] != get_domain(a["url"])){
delete unused_data[a["tabId"]];
dbg_print("Page Changed!!!");