There is also a trick with the stack trace, which is also despised (since it's highly platform-dependent) and ugly to say the least:
function getStackTrace() { return new Error().stack; }
Which would return something like this in chrome's developer's console:
"Error
at getStackTrace (<anonymous>:2:35)
at <anonymous>:2:1
at Object.InjectedScript._evaluateOn (<anonymous>:581:39)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:540:52)
at Object.InjectedScript.evaluate (<anonymous>:459:21)"
and you go with reqular expressions from there.
Will work in Chrome, not sure for others, so it's bad for production-versions. Nice hack though :)