Add javascript automation, rewrite applescript