# HG changeset patch # User Atul Varma # Date 1238602914 25200 # Node ID 7ffb8a48367ee3925b506483e2a4bb8acbd008d3 # Parent 4c4313f338506f3dd04ad56b8864241480455f9f Added initial version of 'my-corporate-stalkers' command. diff -r 4c4313f33850 -r 7ffb8a48367e my-corporate-stalkers/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my-corporate-stalkers/index.html Wed Apr 01 09:21:54 2009 -0700 @@ -0,0 +1,15 @@ + + + + + + My Corporate Stalkers + + +This Ubiquity command tells you what corporations may know about the sites +you visit. This is determined by inspecting all outgoing HTTP requests, +examining who the referrer is, where the destination is, and whether +or not the request contains a cookie. + + diff -r 4c4313f33850 -r 7ffb8a48367e my-corporate-stalkers/my-corporate-stalkers.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my-corporate-stalkers/my-corporate-stalkers.js Wed Apr 01 09:21:54 2009 -0700 @@ -0,0 +1,59 @@ +var observerSvc = Cc["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService); + +if (!globals.refererMatrix) + globals.refererMatrix = {}; + +if (globals.myHttpObserver) { + observerSvc.removeObserver(globals.myHttpObserver, "http-on-modify-request"); + globals.myHttpObserver = null; +} + +globals.myHttpObserver = { + observe: function(subject, topic, data) { + subject = subject.QueryInterface(Ci.nsIHttpChannel); + if (subject.referrer) { + var refHost = subject.referrer.host; + var host = subject.URI.host; + refHost = refHost.split('.').slice(-2).join('.'); + host = host.split('.').slice(-2).join('.'); + if (refHost != host) { + try { + subject.getRequestHeader("Cookie"); + if (!globals.refererMatrix[host]) + globals.refererMatrix[host] = {}; + if (!globals.refererMatrix[host][refHost]) + globals.refererMatrix[host][refHost] = 0; + globals.refererMatrix[host][refHost]++; + } catch (e if e.result == Components.results.NS_ERROR_NOT_AVAILABLE) { + } + } + } + } +}; + +observerSvc.addObserver(globals.myHttpObserver, + "http-on-modify-request", + false); + +CmdUtils.CreateCommand({ + name: "my-corporate-stalkers", + author: {name: "Atul Varma", email: "avarma@mozilla.com", + homepage: "http://www.toolness.com"}, + license: "MIT", + description: ("Shows you what other websites know about you " + + "based on the sites you visit."), + preview: function(pblock) { + var output = ""; + for (host in globals.refererMatrix) { + output += host + " may know that you visit:\n"; + for (refHost in globals.refererMatrix[host]) + output += " " + refHost + "\n"; + output += "\n"; + } + jQuery(pblock).empty(); + jQuery(pblock).append( + jQuery("
", pblock.ownerDocument).text(output)
+    );
+  }
+});