Fix AMD support

This fixes support for AMD loaders like [curl.js](https://github.com/cujojs/curl), probably also #2 (untested).
Snippets are now inserted *before* the first script tag inside the body – if there are no script tags inside the body, the old logic of placing it before `</body>` is used.
It's fix a bit fragile since it uses regexes for HTML-parsing. I found it to break when my first script tag was wrapped inside a comment, however I did not want to use a complete library for DOM manipulation.