codeblog code is freedom — patching my itch

4/9/2006

greasemonkey for RMLS

Filed under: Web — kees @ 8:15 pm

The house-for-sale listings that RMLSweb.com produces are very detailed, and even include a link to show a map for each house’s address. However, this link goes to MapQuest, which I find infuriatingly annoying to use. I wanted the link to at least go to Google Maps instead. Since I live near Portland, I also wanted to search the fantastic Portland Maps site at the same time. That way I could see lot dimensions, crime statistics, etc.

This was clearly a perfect job for GreaseMonkey. The result, after my usual fights with javascript, is my script to override the RMLS address mapping function.

© 2006, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Creative Commons License

3 Comments »

  1. how did you get this to work on firefox? Did you use the IE tab extension? Because thats the way I have it set up on my computer but your script doesn’t seem to work.

    Comment by Anonymous — 5/9/2006 @ 3:23 pm

  2. I’m not sure I understand your question. In firefox, via Greasemonkey, it just works. Of course, I don’t know much about rmlsweb.com. Maybe I didn’t set up the script right; I’ve only been using it from the perspective of RMLS search results sent to me by my agent. (I’d don’t have my own account.)

    I’d be happy to take a patch if you find a better way to have it work. Right now it just installs an override for the “ShowMap” javascript function, which is used on rmlsweb.com’s search results to pop a MapQuest map.

    Thanks!

    Comment by kees — 5/9/2006 @ 4:08 pm

  3. since greasemonkey doesn’t start its work until after a page has fully loaded, I don’t think you need an event listener, and you can add functions into the head like this:

    /*
    linefeeds in the newjs string keep the code readable when you view generated source and can help when you’re debugging in venkman, although line numbers will be a bit off in venkman.
    */

    var newjs=’\n’+
    ‘var foo=”Howdy!”;\n’+
    ‘\n’+
    ‘function bar(foo){\n’+
    ‘ alert(foo);\n’+
    ‘}\n’+
    ‘\n’;

    var newscript=document.createElement(‘script’);
    newscript.setAttribute(‘type’,’text/javascript’);
    newscript.setAttribute(‘id’,’myscript’); // optional
    newscript.innerHTML=newjs;
    var head=document.getElementsByTagName(‘head’).item(0);
    head.appendChild(newscript);

    Comment by Mike — 4/18/2007 @ 4:46 am

Leave a Reply

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

Powered by WordPress