Craigslist GmailTo

By JoeSimmons Last update Aug 4, 2009 — Installed 623 times. Daily Installs: 1, 2, 2, 2, 2, 2, 6, 3, 0, 1, 3, 3, 1, 0, 4, 3, 1, 3, 6, 1, 3, 4, 1, 1, 3, 0, 4, 1, 4, 1, 2, 4

There are 2 previous versions of this script.

// ==UserScript==
// @name           Craigslist GmailTo
// @namespace      http://userscripts.org/users/23652
// @description    Makes craigslist emails go to Gmail instead of the default mail service
// @include        http://*.craigslist.org/*
// @include        http://craigslist.org/*
// @copyright      JoeSimmons
// @version        1.0.1
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

function main() {
var array = window.document.evaluate("//a[starts-with(@href,'mailto:')]",document,null,6,null),
	sub_re = /subject=([^&]*)/,
	attr={to:'',subject:''}, href;
for(var i=array.snapshotLength-1; (item=array.snapshotItem(i)); i--) {
href=item.href;
attr['subject'] = (href.indexOf('subject=')!=-1) ? href.match(sub_re)[1] : '';
attr['to'] = (href.indexOf('@craigslist.org')!=-1) ? href.split('mailto:')[1].split('?')[0] : '';
if(attr['to']!='') {
item.setAttribute('target', '_blank');
item.href = 'https://mail.google.com/?view=cm&fs=1&tf=1&to='+attr['to']+(attr['subject']!=''?'&su='+attr['subject']:'');
}
}
}

main();

window.addEventListener('DOMSubtreeModified', main, false);