Fixed HierarchyRequestError in Chrome

I could not get the detector javascript to run on Chrome without JS throwing a HierarchyRequestError. It seemed that the JS was trying to insert the dynamically created <script> tag inside the opening <html> tag. 

I just copied what GA does instead, searching for the first <script tag> (guaranteed to be at least one ... ours) and inserting after that.

Apologies it's in 3 commits. It's quite late here.