[jQuery] Add a callback to any method

[jQuery] Add a callback to any method


I'd like to be able to do something like this
//Extend Function for easy callbacks
Function.prototype.andThen=function(g) {
var f=this;
return function() {
f();g();
}
};
$('div[class="rating"]').livequery(function(){
    var $this = $(this);
    var opts = function(){
        g.ratingOpts.self = $this;
        g.ratingOpts.curvalue = parseInt($this.attr("rate"));
return g.ratingOpts;
    }();
    $this.rating(opts);
}).andThen(function(){
alert("I'm called after livequery has looped through all the div's
with class rating");
});
I realize that touching Function.prototype might not be the best idea.
Is there anything like this out there somewhere? I would like to have
to touch the plugins, etc, so that scripts can be updated without
having to go through them again and add in callbacks-