In general, the code snippet provided should do the trick. I suspect the results you are seeing is because you have enabled the Run in Iframes feature on the General Settings page and hence grabbing iframe information as well. If this is not the case, if you provide the extension id I can take a look and try and assist you further.
[Disclosure: I am a Crossrider employee]