New (working) version of autoprint in JavaScript.