aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contact_finder.js78
-rw-r--r--html/display_panel/content/main_panel.js1
-rw-r--r--main_background.js74
3 files changed, 150 insertions, 3 deletions
diff --git a/contact_finder.js b/contact_finder.js
new file mode 100644
index 0000000..759b3b0
--- /dev/null
+++ b/contact_finder.js
@@ -0,0 +1,78 @@
+// TO TEST THE CONTACT FINDER:
+// - open the manifest.json
+// - add a comma after the closing bracket of the key "background"
+// - Copy and paste this after it:
+/*
+ "content_scripts": [{"matches": ["<all_urls>"],"js": ["contact_finder.js"]}]
+*/
+// Now, the contact finder will load on every page and you can test it where ever you want.
+
+var button_i = 0;
+if(document.getElementById("abc123_main_div") !== null){
+ document.getElementById("abc123_main_div").remove();
+}
+function new_debug_button(name_text,callback){
+ if(document.getElementById("abc123_main_div") === null){
+ var to_insert = '<div style="opacity: 0.5; font-size: small; z-index: 2147483647; position: fixed; right: 1%; top: 4%;" id="abc123_main_div"></div>';
+ document.body.insertAdjacentHTML('afterbegin', to_insert);
+ }
+ var button_html = '<input id="abc123_button_' + button_i + '" value="' + name_text +'"type="button"></input><br>';
+ document.getElementById("abc123_main_div").insertAdjacentHTML('afterbegin', button_html);
+ document.getElementById("abc123_button_"+button_i).addEventListener("click",callback);
+ button_i = button_i + 1;
+}
+/**
+* "LibreJS detects contact pages, email addresses that are likely to be owned by the
+* maintainer of the site, Twitter and identi.ca links, and phone numbers."
+*/
+function find_contacts(){
+ var all = document.documentElement.innerHTML;
+ var emails = [];
+ emails.push(all.match(/\S+@\S+\.\S+\b/g));
+ // 1.555.123.4567
+ //+1.555.123.4567
+ var phone_num = [];
+ phone_num.push(all.match(/(\d{1,3}\.)?(\d\d\d)\.(\d\d\d)\.(\d\d\d\d)/g));
+ // 1-555-123-4567
+ //+1-555-123-4567
+ phone_num.push(all.match(/(\+?\d)?([\-|\.])(\d\d\d)\2(\d\d\d)\2(\d\d\d\d)/g));
+ // +15554567890
+ phone_num.push(all.match(/\+?\d{10,15}\b/g));
+ // twitter handles
+ var twitter = [];
+ twitter.push(all.match(/@\w{3,15}\b/g));
+ // twitter links
+ var twitlinks = [];
+ twitlinks.push(all.match(/twitter\.com\/\w{3,15}\b/g));
+ // identi.ca link
+ // 25 is my guess at the max username length (I don't actually know)
+ var identi = [];
+ identi.push(all.match(/identi\.ca\/\w{3,25}\b/g));
+ // Attempt to find contact pages
+ var contact_pages = [];
+ var links = document.getElementsByTagName("a");
+ for(i in links){
+ if(links[i].href !== undefined && links[i].href.indexOf("contact") != -1){
+ contact_pages.push(links[i]);
+ }
+ }
+ console.log("********************************************************");
+ console.log("%c RESULTS: ","color: #dd0000;");
+ console.log("%c " + phone_num.length + "%c phone numbers","color: red;","color: purple;");
+ console.log("%c " + twitter.length + "%c twitter handles","color: red;","color: purple;");
+ console.log("%c " + twitlinks.length + "%c twitter links","color: red;","color: purple;");
+ console.log("%c " + identi.length + "%c identi.ca links","color: red;","color: purple;");
+ console.log("%c " + contact_pages.length + "%c possible contact pages","color: red;","color: purple;");
+ console.log("********************************************************");
+
+
+
+
+}
+
+new_debug_button("Complain to website",find_contacts);
+new_debug_button("Remove these buttons",function(){
+ if(document.getElementById("abc123_main_div") !== null){
+ document.getElementById("abc123_main_div").remove();
+ }
+});
diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js
index 8595b5a..19cad89 100644
--- a/html/display_panel/content/main_panel.js
+++ b/html/display_panel/content/main_panel.js
@@ -96,6 +96,7 @@ function write_elements(data,name,color){
var temp = current_blocked_data[name][parseInt(info.path[0].id.match(/\d/g)[1])];
console.log("Forget preferences for script " + temp[0]);
var script_name = this.parentElement.parentElement.parentElement.parentElement.id;
+ this.parentElement.parentElement.getElementsByTagName("b")[0].insertAdjacentHTML("beforebegin","<h3>Refresh the page to revaluate this script.</h3>");
myPort.postMessage({"forget": temp});
});
}
diff --git a/main_background.js b/main_background.js
index f5fe02d..75a5917 100644
--- a/main_background.js
+++ b/main_background.js
@@ -95,8 +95,6 @@ function debug_print_local(){
* }
*
*/
-// This might be wasting memory
-// I now realize it doesn't need to store the connections, this is left over from when I thought it did
var active_connections = {};
var unused_data = {};
function update_popup(tab_id,blocked_info_arg,update=false){
@@ -314,11 +312,81 @@ function init_addon(){
update_popup(4,example_input);
console.log("Set the browser action contents");
/*****************************************************************/
+}
+/**
+* Test if a page is whitelisted/blacklisted.
+*
+* The input here is tested against the comma seperated string found in the options.
+*
+* It does NOT test against the individual entries created by hitting the "whitelist"
+* button for a script in the browser action.
+*
+*
+*
+*/
+function test_url_whitelisted(url,callback){
+ function storage_got(items){
+ var wl = items["pref_whitelist"].split(",");
+ var regex;
-
+ for(i in wl){
+ var s = wl[i].replace(/\*/g,"\\S*");
+ s = s.replace(/\./g,"\\.");
+ regex = new RegExp(s, "g");
+ if(url.match(regex)){
+ //callback("%c" + wl[i] + " matched " + url,"color: purple;");
+ callback(true);
+ } else{
+ //console.log("%c" + wl[i] + " didn't match " + url,"color: #dd0000;");
+ }
+ }
+ callback(false);
+ }
+ webex.storage.local.get(storage_got);
}
+function inject_contact_finder(tab_id){
+ function executed(result) {
+ console.log("[TABID:"+tab_id+"]"+"finished executing contact finder: " + result);
+ }
+ var executing = webex.tabs.executeScript(tab_id, {file: "/contact_finder.js"}, executed);
+}
+
init_addon();
+/***************** test the comma seperated whitelist *****************/
+/*
+var test_urls = [
+ "example.subdomain.test.com/",
+ "http://example.subdomain.test.com",
+ "http://0xbeef.coffee",
+ "https://webchat.freenode.net/",
+ "https://www.chromium.org/Home/chromium-security/client-identification-mechanisms",
+ "http://stackoverflow.com/questions/874709",
+ "https://postcalc.usps.com",
+ "http://regexr.com/",
+ "https://pgw.ceca.es/tpvweb/tpv/compra.action",
+ "This is total garbage input",
+ "http://home.com/test",
+ "https://home.com/test"
+]
+
+function callback(a){console.log(a);}
+
+for(i in test_urls){
+ test_url_whitelisted(test_urls[i],callback);
+}
+*/
+/*******************************************************************/
+
+
+
+
+
+
+
+
+
+