Proto.Spy

A while back a friend of mine mentioned this site to me: It checks which porn sites you have been on.

The technology used to achieve this is quite simple. It inserts links to a bunch of porn sites in the page and uses Javascript to check the link color, abusing the fact that browsers by default use different colors for links you have visited or have not.

Some days ago I came across a blog post by David Walsh in which he described how to perform the above described check using jQuery. I was amazed how easy that was and thought it must be equaly easy to do the same using Prototype. Well, here we go:

I’ve set up a demo that checks a small number of sites (no porn, sorry).

Here is the small function I use to do the checks:

Event.observe(window,'load',function(){
 siteList.each(function(site){
  var a = new Element('a', { href: 'http://' + site, }).addClassName('check').insert(site);
  if(a.getStyle('color') == '#800080' || a.getStyle('color') == 'rgb(0, 128, 0)') {
   $('link-list').insert(a.addClassName('highlight').removeClassName('check').wrap('li'));
  } else {
   var b = new Element('a', { href: 'http://www.' + site }).addClassName('check').insert(site);
   if(b.getStyle('color') == '#800080' || b.getStyle('color') == 'rgb(0, 128, 0)') {
    $('link-list').insert(b.addClassName('highlight').removeClassName('check').wrap('li'));
   } else {
    $('link-list').insert(a.removeClassName('check').wrap('li'));
   }
  }
 });
},false);

with siteList being an array of sites that will be checked. The basically creates an anchor element for each site in the array and checks that elements color. If it matches my defined css style for visited links, than I add the class name ‘highlight’ to the element, otherwise I don’t. That’s pretty much what David Walsh does aswell, but additionally to that I check both http://example.com and http://www.example.com as some might have visited the one but not the other. If none were visited, I show the http://example.com link.

Any questions? No? Then start abusing this ;)

P.S.: This is an older post I copied from my old blog. Thought some of you might find this useful.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.