There is a project called jsinspect which does what you are talking about.
I dont know if yours would be a bit more robust than this one.. But just wanted to provide this - so you know what you are competing with.
Thanks, I've seen jsinspect. It works by comparing ASTs, which is probably than matching strings, but I guess it wouldn't be able to deal with inlined functions or reordered code segments etc.