Once upon a time i was wondered how easy was to break through the javascript obfuscation to rip data from the web page with Javascript.pm.
Which is the intreface to the stand-alone JS interpreter by Mozilla project.
Of course the functionality should be additionally elaborated on DOM behavior imitation.But it does just what you ask: evaluates JS function as Perl function.