Inline js would be better, then you could interact with the surrounding code, and avoid the slowness of eval too. Yes, this hack would be great in a macro for that.