As far as I know it should be straightforward to add JavaScript to the widget area. I recommend installing the Classic Widgets plugin first, which will restore the old style widgets page. Then drag a Custom HTML widget into the sidebar area and paste your JavaScript into it, between <script> and </script> tags. It should just work.