I have come to love jQuery - It is incredibly slick to automate basic tasks. The winning combination is being able to dynamically load jQuery with a browser plugin called greasemonkey (wikipedia entry).
I got sick of always having to log-in to a specific site and click through links to get to what I wanted, so here is a sample of a userscript that logs me in and manipulates things the way I want them to. I have written some other ones to do extra calculations on top of finance.yahoo.com pages. Its a handy combination.
Of course to round out the development of these scripts don’t forget to use FireBug!!
// ==UserScript==
// @name Crestock
// @namespace net.colinharrington
// @include www.crestock.com
// @include crestock.com
// ==/UserScript==
var my_username = 'username'; //fill this in yourself...
var my_password = 'password'; //again use your own...
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
function GM_wait() {
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();
// All your GM code must be inside this function
function letsJQuery() {
$('#ctl00_cphMainContent_txtUsername').attr('value',my_username);
$('#ctl00_cphMainContent_txtPassword').attr('value',my_password);
$('#ctl00_cphMainContent_btnLogin').click();
$('#ctl00_cphMainContent_cbContentAgreement').click();
$('a#ctl00_cphMainContent_btnDownload').attr('onclick',$('a#ctl00_cphMainContent_btnDownload').attr('href'));
$('a#ctl00_cphMainContent_btnDownload').click();
}
I may get around to submitting some of these to the public repository over at http://userscripts.org/.
Enjoy!