Another idea would be to make all render.{html,png,json} support POST'ing javascript (if content-type=application/json) and return the rendered page after executing that javascript (which may produce changes on the page).

Neither render.html nor render.png would return the actualy result of the js script, for that we could add new field to render.json  - "script", "js", "jsoutput" - and include the result there, if it's passed in the arguments as one of the fields to return (like html, png, iframes). So an actual example would look something like this:

    curl -X POST -H "content-type: application/javascript" -d "function getAd(x){ return x; } getAd('abc');" "http://localhost:8050/render.json?url=http://domain.com&script=1"

And that would return a json like:

    {
        "url": "http://domain.com/",
        "geometry": [0, 0, 640, 480],
        "requestedUrl": "http://domain.com/",
        "title": "Page title"
        "script": "HERE IS THE RESULT OF getAd('abc')",
    }