Mercurial > my-ubiquity-commands
changeset 15:7ffb8a48367e
Added initial version of 'my-corporate-stalkers' command.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 01 Apr 2009 09:21:54 -0700 |
parents | 4c4313f33850 |
children | 426e9c04c6f9 |
files | my-corporate-stalkers/index.html my-corporate-stalkers/my-corporate-stalkers.js |
diffstat | 2 files changed, 74 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <link rel="commands" href="my-corporate-stalkers.js"/> + <title>My Corporate Stalkers</title> +</head> +<body> +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. +</body> +</html>
--- /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("<pre></pre>", pblock.ownerDocument).text(output) + ); + } +});