« Adding Gravitar To Your Websi... «

Fight Spam With JavaScript

Michael Deering April 15th, 2008

I’m willing to bet that email harvesting spam crawlers don’t have any capabilities to deal with JavaScript.

As an alternative to the many readable only to a human expressions such as mdeering – at – mdeering – dot – com why not try the following.

If you are visting this site with JavaScript disabled you will see content matching the following image in the “Quick Contact” area in the footer of all this sites pages.

Contact Information With JavaScript Disabled

If you are visiting this site with JavaScript enabled you will see content matching the following image in the “Quick Contact” area in the footer of all this sites pages.

Contact Information With JavaScript Enabled

My application view template renders the following div with the id of ‘quick_contact’ on every page of this site.

<div class="footer_column">
  <h3>Quick Contact</h3>
  <div id="quick_contact">
    To avoid spam this information is only available to browsers with javascript enabled.
  </div>
</div>

When the page loads the JavaScript function ‘addQuickContactInfo’ is called to populate my contact information.


function addQuickContactInfo() {
// Do the minimum to hide my email with this replace
 var email        = 'spam@example.com'.replace(/(spam|example)/g, 'mdeering');
// Use the same technique as above to hide my phone number
 var phone_number = '555.444.3333'.replace(/555/, '780').replace(/444/, '906').replace(/3333/, '6632');
 this.addClassName('vcard');
// Clear out the static content from the div
 this.update('');
// Next 4 lines just populate the div with the information
 this.appendChild( $div( {'class': 'fn org'}, 'Michael Deering' ) );
 this.appendChild( $div( {'class': 'email'}, $a( {href: 'mailto:' + email}, email ) ) );
 this.appendChild( $div( {'class': 'url'}, $a( {href: 'http://mdeering.com'}, 'http://mdeering.com' ) ) );
 this.appendChild( $div( {'class': 'tel'}, $span( {'class': 'type'}, 'Cell' ), ': ', $span( {'class': 'value'}, phone_number ) ) );
}

Event.addBehavior({
  '#quick_contact':               addQuickContactInfo,
});

I’m using the LowPro and Prototype JavaScript libraries here obviously.

What do you think, did I just send my spam filter into overdrive, or is this a viable alternative to cryptic contact information?

Tags

4 comments so far

Avatar by dstar 11 hours later

Congratulations, you just ensured that anyone who doesn’t have javascript enabled (such as me, as ~90% of my web browsing is done through elinks) can’t contact you unless they read the source and understand the javascript, while buying yourself only limited time before the spam-bots get your address.

Rule 1: Spammers are clever. They will adapt to things like this. If a browser can read and parse the source, a spam-bot can as well. If something like this becomes common, then spam-bots will simply a) run the javascript on the page and scrape the generated html or b) run the javascript on the page and check each variable to see if it looks like an email address.

Plus, how well does this play with screen readers for the visually impaired?

Avatar by Michael Deering 15 hours later

@dstart

To answer your points.

If you want my contact information just pull it out how you would if I had not replaced it with javascript. mdeering – at – mdeering – dot – com.

The clever spammers are going to realize that by not using javascript rendering tools (they would be magnitudes slower then the text based Unix tools I’m sure they are using) and just adjusting their RegExp to match frank at something dot com they will harvest 1000% more email addresses for 1% of the effort. I’m sure they are pragmatic just like the rest of us ;)

Avatar by austin_web_developer 1 week later

I really like this idea … don’t know why it didn’t occur to me earlier.

Have you been getting spam before you put it in place? Has the spam dropped off?

Avatar by Michael Deering 1 week later

To be completely honest I host all my email through GMail. I squat on host about 15 domains that all have catch-all email addresses so the amount of spam I get is pretty insane. I never get to see ANY of the spam mind you (I’m truly blown away at how effective GMail’s spam filtering is) but I have not noticed any real increase in the number I empty out of the spam filter every few days.

Post A Comment


Or I will pick one for you!

For that cool little Gravitar icon!

You shameless self promoter!


Format with Textile if you wish.