Using Javascript to get MOS in TNEW

Is anyone doing this?  I have a script which works in the console, but has serious problems when I embed it in the page.  The main issue is that the location of that information (a comment after the </body> tag but before the </html> tag) is very difficult to identify cleanly and access in the document object.