Contents |
[edit]
Introduction
Fresno provides unix command line access to the Javascript interpreter of your running Firefox instance.
It is a complement to MozRepl, so you will need to have that installed and running in your firefox.
[edit]
Why do I Care?
Here's an example of what you can do. This visits a web page, plucks out the HTML for a portion of the page, and then uses grep to pick out the hrefs.
% ./fresno -p http://simile.mit.edu/ -c -j "document.getElementById('slideshow').innerHTML" \
| grep href
<div class="title"><a href="semantic-bank/">Semantic Bank</a></div>
<div class="title"><a href="gadget/">Gadget</a></div>
<div class="title"><a href="welkin/">Welkin</a></div>
<div class="title"><a href="timeline/">Timeline</a></div>
<div class="title"><a href="referee/">Referee</a></div>
<div class="title"><a href="babel/">Babel</a></div>
<div class="title"><a href="exhibit/">Exhibit</a></div>
<div class="title"><a href="appalachian/">Appalachian</a></div>
%
[edit]
How do I get it?
Install it pulling it from our SVN repository, as so:
svn co http://simile.mit.edu/repository/fresno/trunk fresno
[edit]
Usage
./fresno <args> -p <url> -- Move browser to this page -j <javascript expr> -- evaluate this expression -e <javascript expr> -- enter's the object before running the script -c -- equivalent to: -e content -l <javascript filename> -- load javascript file, done prior to any -e -v -- run verbose -h -- this help message
[edit]
Examples
Send your browser to a page:
% ./fresno -p http://simile.mit.edu/wiki/Fresno
Find our what page your visiting:
% ./fresno -j content.location.href http://simile.mit.edu/
Reload that page:
% ./fresno -j 'content.location.reload()'
MozRepl's routines are, of course available. The default context it runs in is the ChromeWindow
% ./fresno -j 'repl.whereAmI()' [object ChromeWindow] - Document title: "about:config"
But you can switch to the content Window.
% ./fresno -c -j 'repl.whereAmI()' [object Window] - Document title: "about:config"
MozRepl has lots of useful reoutines, for example you can inspect objects:
% ./fresno -c -j 'repl.inspect(location)' <object>.href=http://simile.mit.edu/ <object>.search= <object>.hash= <object>.host=simile.mit.edu <object>.hostname=simile.mit.edu <object>.pathname=/ <object>.port= <object>.protocol=http: <object>.replace=[function] <object>.assign=[function] <object>.reload=[function]
There are lots of things around
% ./fresno -j 'repl.inspect(this)' | wc -l
963
% ./fresno -j 'repl.inspect(Components.classes)' | wc -l
862
% ./fresno -j 'repl.inspect(content)' | wc -l
197
% ./fresno -j 'repl.inspect(XULBrowserWindow)' | wc -l
37
%
[edit]
Bugs
- Add bugs here
- When js command return a string beginning by dash -, expect interpret it as an option. Two dashes must be added after (probably) every send and send_user commands. eg: doOutput='send_user -- $expect_out(1,string)' --JJL 23:24, 1 May 2008 (UTC)
[edit]
Thanks
- Massimiliano Mirra for MozRepl, and enhancements and fixes to Fresno.
[edit]
See also
- Fresno FAQ
- README file.
- Audio about the (historical agricultural) Fresno Scraper (after which fresno is named)
- PDF about the Fresno Scraper (ditto)
- Fresno Todos

